Skip to main content

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). Build returns them.
  • Elements are the long-lived instances that Sway diffs against the new widgets. They hold State, resolve inherited lookups such as Theme.Of(context) and Directionality.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-style Grid, lazy ListView.Builder and GridView.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 as AnimatedContainer.
  • Navigation: Router with URL routes, redirects and transitions.
  • Effects: shadows, gradients, clips, transforms, blur and colour filters, and RepaintBoundary to cache static subtrees.
  • Localization: Locale, Localizations and delegates.
  • File pickers and an Image widget.

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.Fiori and Sway.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 in Sway.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​