Introduction
Sway is a .NET UI toolkit with a Flutter-style widget system. You describe your interface as a tree of immutable widgets in C#. Sway diffs the tree, lays it out with box constraints, and paints it with SkiaSharp. There is no browser, WebView or XAML behind it.
// using Sway.Extras.Material3;
App.Run(new MaterialApp(home: new CounterPage()), "My App", 800, 600);
class CounterPage : StatefulWidget
{
public override State CreateState() => new CounterPageState();
}
class CounterPageState : State<CounterPage>
{
int _count;
public override Widget Build(BuildContext context) => new Scaffold(
appBar: new AppBar(title: new Text("Counter")),
body: new Center(new Text($"Count: {_count}", style: Theme.Of(context).TextTheme.DisplaySmall)),
floatingActionButton: new FloatingActionButton(new Icon(Icons.Add), () => SetState(() => _count++)));
}
The model
Sway follows Flutter's three trees:
- Widgets are cheap, immutable descriptions (
Container,Row,Text,TextField).Buildreturns them. - Elements are the long-lived instances that Sway diffs against the new widgets. They hold
State, resolve inherited lookups such asTheme.Of(context)andDirectionality.Of(context), and decide what to rebuild. - Render objects do layout (constraints go down, sizes go up), painting and hit testing.
What is included
Core (Sway.Widgets)
- Layout:
Row,Column,Flex,Stack,Wrap, a CSS-styleGrid, lazyListView.BuilderandGridView.Builder,LayoutBuilder,Padding,Align,SizedBox,AspectRatio, intrinsic sizing. - Text: HarfBuzz shaping, wrapping, rich spans, bidirectional text, right-to-left layout, and an editor with selection, clipboard and undo.
- Input: a gesture arena (tap, double-tap, long-press, drag), hover and cursors, focus and Tab traversal, scrolling with fling and scrollbars, touch scrolling.
- Animation:
AnimationController, curves, tweens, springs, transitions, and implicit widgets such asAnimatedContainer. - Navigation:
Routerwith URL routes, redirects and transitions. - Effects: shadows, gradients, clips, transforms, blur and colour filters, and
RepaintBoundaryto cache static subtrees. - Localization:
Locale,Localizationsand delegates. - File pickers and an
Imagewidget.
Hosts
Desktop (Windows, Linux, macOS; Sway.Platform.Desktop), Android (Sway.Platform.Android), the browser
(Sway.Platform.Web) and a headless host that renders to PNG (Sway.Platform.Headless).
Optional packages
Sway.Extras.Material3: Material 3 with seeded colour schemes, light and dark modes, and the component set.Sway.Extras.Ibm: IBM Carbon, with its own tokens, IBM Plex, form controls and a data table.Sway.Extras.FioriandSway.Extras.Shopify: SAP Fiori and a phone-first commerce kit.Sway.Gl: OpenGL scenes inside the widget tree.Sway.Media: video and audio on LibVLC or the browser, with Material 3 players inSway.Extras.Material3.Media.
What is not (yet)
Sway is young. Known limits lists every gap. The main ones: no accessibility tree, no emoji or per-character font fallback, single-pointer input (no pinch or multi-touch gestures), one window per process, no ripple effects, and only Windows is well tested.
Next steps
- Getting started: run the demo and write your first widget.
- Widgets: layout, painting, text and overlays.
- Theming: Material 3, colour schemes and dark mode.
- IBM Carbon and More design systems: the other component sets.
- Input and focus: gestures, scrolling, text fields and the keyboard.
- Navigation:
Router, links and history. - Animation: controllers, tweens and implicit animations.
- OpenGL: embedding your own GL rendering.
- Architecture: how a widget becomes pixels.