TimeWarp.Flexbox 1.0.0

Prefix Reserved
dotnet add package TimeWarp.Flexbox --version 1.0.0
                    
NuGet\Install-Package TimeWarp.Flexbox -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TimeWarp.Flexbox" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TimeWarp.Flexbox" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="TimeWarp.Flexbox" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TimeWarp.Flexbox --version 1.0.0
                    
#r "nuget: TimeWarp.Flexbox, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TimeWarp.Flexbox@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TimeWarp.Flexbox&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=TimeWarp.Flexbox&version=1.0.0
                    
Install as a Cake Tool

TimeWarp.Flexbox

A pure C# implementation of the Flexbox layout algorithm for .NET applications.

TimeWarp.Flexbox is a from-scratch C# port of the algorithm behind Facebook's Yoga layout engine. It computes CSS-flexbox layouts (positions and sizes) for a tree of nodes — no UI framework required — and its behavior is verified against Yoga's own generated conformance suite (530 tests, LTR and RTL).

The library has zero runtime dependencies and is fully Native AOT and trimming compatible (IsAotCompatible): no reflection, no dynamic code. A PublishAot smoke test runs in CI on every build.

Installation

dotnet add package TimeWarp.Flexbox
<PackageReference Include="TimeWarp.Flexbox" Version="1.0.0" />

Usage

using TimeWarp.Flexbox;

// Create a flex container
Node root = new();
root.Style.FlexDirection = FlexDirection.Row;
root.Style.SetDimension(Dimension.Width, StyleSizeLength.Points(300));
root.Style.SetDimension(Dimension.Height, StyleSizeLength.Points(200));

// Add children that share the free space 1:2
Node left = new();
left.Style.FlexGrow = 1;
root.InsertChild(left, 0);

Node right = new();
right.Style.FlexGrow = 2;
root.InsertChild(right, 1);

// Calculate layout
CalculateLayout.Calculate(root, float.NaN, float.NaN, Direction.LTR);

// Read computed positions and sizes
Console.WriteLine($"left:  x={left.Layout.GetPosition(PhysicalEdge.Left)} width={left.Layout.GetDimension(Dimension.Width)}");
Console.WriteLine($"right: x={right.Layout.GetPosition(PhysicalEdge.Left)} width={right.Layout.GetDimension(Dimension.Width)}");
// left:  x=0 width=100
// right: x=100 width=200

Styles are set through Node.Style:

  • Dimensions: SetDimension, SetMinDimension, SetMaxDimension with StyleSizeLength.Points(..), .Percent(..), .Auto
  • Flex: FlexDirection, FlexGrow, FlexShrink, FlexBasis, FlexWrap
  • Alignment: JustifyContent, AlignItems, AlignSelf, AlignContent
  • Box model: SetMargin, SetPadding, SetBorder per Edge, SetGap per Gutter
  • Positioning: PositionType (relative/absolute/static) with SetPosition insets

Results are read from Node.Layout after calling CalculateLayout.Calculate (or the equivalent instance convenience root.CalculateLayout()): GetPosition(PhysicalEdge) and GetDimension(Dimension).

Defaults

Defaults match Yoga (not web CSS): flex-direction: column, flex-shrink: 0, align-content: flex-start, and box-sizing: border-box. Construct nodes with new Node(new Config { UseWebDefaults = true }) for web-style defaults.

Demo

Run the visual demo to see computed layouts rendered as ASCII boxes, or as an HTML page comparing the engine's output against your browser's native flexbox:

./samples/layout-demo/layout-demo.cs                 # terminal
./samples/layout-demo/layout-demo.cs --html out.html # browser comparison

License

MIT — see LICENSE for details. Behavior modeled on Facebook's Yoga (MIT, Copyright (c) Meta Platforms, Inc.).

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 95 7/4/2026
1.0.0-beta.4 58 7/4/2026