3 unstable releases

0.2.0 Aug 13, 2024
0.1.1 Aug 4, 2024
0.1.0 Feb 4, 2024

#1271 in GUI

Download history 72/week @ 2024-07-29 42/week @ 2024-08-05 124/week @ 2024-08-12 16/week @ 2024-09-16 9/week @ 2024-09-23 34/week @ 2024-09-30

126 downloads per month

MIT license

660KB
1.5K SLoC

Textyle

A layout engine inspired by SwiftUI and declarative UI frameworks. Originally focused on text and terminal graphics.

Examples

I plan on making a DSL for it, but these examples use the rust Enum based API for now:

1- Sidebar layout

This code:

let layout = Layout::HorizontalStack( VerticalAlignment::Top, vec![
        Layout::text("Main content")
            .center_horizontally()
            .align_top()
            .padding_vertical(2)
            .border(2, '.', hash_set!(Edge::Right)),
        Layout::VerticalStack(HorizontalAlignment::Center, vec![
            Layout::text("Side content"),
            Layout::VerticalStack(HorizontalAlignment::Left, vec![
                Layout::text("List of content:")
                .padding(1),
                Layout::text("- Item 1"),
                Layout::text("- Item 2"),
                Layout::text("- Item 3"),
            ])
            .border(1, '-', hash_set![Edge::Top])
        ])
        .center_horizontally()
        .width(24)
        .padding_vertical(2)
    ]);

Produces the following UI:

example_big

If the canvas is given smaller dimensions, the declarative layout adapts:

example_small

Dependencies

~1.5–6.5MB
~32K SLoC