Stack
Stacks children vertically with a configurable gap. By default each child fills the available width.
Attributes
Section titled “Attributes”| Attribute | Type | Default | Description |
|---|---|---|---|
gap |
token/pt | — | Space between children: xs s m l xl xxl or 12pt |
align |
string | stretch |
Cross-axis alignment: start center end stretch |
justify |
string | start |
Main-axis distribution: start center end between |
width |
token/pt | — | Constrain width |
padding |
spacing | — | Inner padding: 16pt or shorthand "16pt 12pt" |
background |
color | — | Background color |
border |
string | — | Border: "s #cccccc" or "1pt #cccccc" |
radius |
token/pt | — | Corner radius |
height |
pt/fill/full |
— | Fixed height, fill remaining space, or full page height |
font |
string | inherit | Font name (declared in assets) |
font-size |
token/pt | inherit | Font size for all children |
data-source |
string | — | Dot-path to array — repeats this element per item |
data-if |
string | — | Render only when value is truthy |
data-if-not |
string | — | Render only when value is falsy |
Basic example
Section titled “Basic example”<stack gap="16pt"> <text font-size="18pt">Title</text> <divider/> <text>Body text.</text></stack>L.stack({ gap: '16pt' }, [ L.text({ fontSize: '18pt' }, ['Title']), L.divider(NoAttr), L.text(NoAttr, ['Body text.']),])L.stack(StackAttr(gap='16pt'), [ L.text(TextAttr(font_size='18pt'), ['Title']), L.divider(NoAttr), L.text(NoAttr, ['Body text.'])])L::stack(new StackAttr(gap: '16pt'), [ L::text(new TextAttr(fontSize: '18pt'), ['Title']), L::divider(NoAttr), L::text(NoAttr, ['Body text.']),])L.Stack(new() { Gap = "16pt" }, [ L.Text(new() { FontSize = "18pt" }, ["Title"]), L.Divider(NoAttr), L.Text(NoAttr, ["Body text."]),])Centered content
Section titled “Centered content”<stack gap="12pt" align="center"> <text>Centered item</text> <text>Also centered</text></stack>L.stack({ gap: '12pt', align: 'center' }, [ L.text(NoAttr, ['Centered item']), L.text(NoAttr, ['Also centered']),])L.stack(StackAttr(gap='12pt', align='center'), [ L.text(NoAttr, ['Centered item']), L.text(NoAttr, ['Also centered'])])L::stack(new StackAttr(gap: '12pt', align: 'center'), [ L::text(NoAttr, ['Centered item']), L::text(NoAttr, ['Also centered']),])L.Stack(new() { Gap = "12pt", Align = "center" }, [ L.Text(NoAttr, ["Centered item"]), L.Text(NoAttr, ["Also centered"]),])Space between (like flex justify-content: space-between)
Section titled “Space between (like flex justify-content: space-between)”<stack justify="between" height="full"> <text>Top</text> <text>Bottom</text></stack>L.stack({ justify: 'between', height: 'full' }, [ L.text(NoAttr, ['Top']), L.text(NoAttr, ['Bottom']),])L.stack(StackAttr(justify='between', height='full'), [ L.text(NoAttr, ['Top']), L.text(NoAttr, ['Bottom'])])L::stack(new StackAttr(justify: 'between', height: 'full'), [ L::text(NoAttr, ['Top']), L::text(NoAttr, ['Bottom']),])L.Stack(new() { Justify = "between", Height = "full" }, [ L.Text(NoAttr, ["Top"]), L.Text(NoAttr, ["Bottom"]),])Card with background and border
Section titled “Card with background and border”<stack gap="8pt" padding="m" background="#f8f9fa" border="xs #e0e0e0" radius="s"> <text font-size="s">Card title</text> <text font-size="xs" color="#666666">Supporting text.</text></stack>L.stack({ gap: '8pt', padding: 'm', background: '#f8f9fa', border: 'xs #e0e0e0', radius: 's' }, [ L.text({ fontSize: 's' }, ['Card title']), L.text({ fontSize: 'xs', color: '#666666' }, ['Supporting text.']),])L.stack(StackAttr(gap='8pt', padding='m', background='#f8f9fa', border='xs #e0e0e0', radius='s'), [ L.text(TextAttr(font_size='s'), ['Card title']), L.text(TextAttr(font_size='xs', color='#666666'), ['Supporting text.'])])L::stack(new StackAttr(gap: '8pt', padding: 'm', background: '#f8f9fa', border: 'xs #e0e0e0', radius: 's'), [ L::text(new TextAttr(fontSize: 's'), ['Card title']), L::text(new TextAttr(fontSize: 'xs', color: '#666666'), ['Supporting text.']),])L.Stack(new() { Gap = "8pt", Padding = "m", Background = "#f8f9fa", Border = "xs #e0e0e0", Radius = "s" }, [ L.Text(new() { FontSize = "s" }, ["Card title"]), L.Text(new() { FontSize = "xs", Color = "#666666" }, ["Supporting text."]),])