Stack
Things one under the other, with the same space between them. The space is a step of the scale, so every screen breathes alike.
import { Stack } from '@sypnia/ui/react'
A settings form
gap takes a step of the scale (0–10) or any CSS length. Stacks inside stacks keep their own gap.
One line for the team.
Gap 1 between these two linesand gap 4 between the fields above.
Code
import { Button, Field, Input, Stack, Textarea } from '@sypnia/ui/react';
export default function Settings() {
return (
<Stack gap={4} style={{ maxWidth: '28rem' }}>
<Field label="Project name"><Input defaultValue="Checkout" /></Field>
<Field label="Description" hint="One line for the team."><Textarea rows={2} defaultValue="Payments and orders." /></Field>
<Stack gap={1}>
<strong>Gap 1 between these two lines</strong>
<span className="sy-text--muted">and gap 4 between the fields above.</span>
</Stack>
<div><Button variant="primary">Save</Button></div>
</Stack>
);
} In Astro
The same helper as an Astro component, with no JavaScript. In plain HTML it is the class sy-stack and the variable --gap.
Code
---
import Stack from '@sypnia/ui/astro/Stack.astro';
import Button from '@sypnia/ui/astro/Button.astro';
---
<Stack gap={3}>
<p>A static page uses the same helpers, without JavaScript.</p>
<p class="sy-text--muted">Gap 3 is <code>var(--s-3)</code>, 0.75rem.</p>
<div><Button variant="secondary" href="#">Read more</Button></div>
</Stack> When to use it
Use it when
- Content flows down: the fields of a form, the sections of a panel, a list of cards.
- You would otherwise write
margin-topbetween siblings.
Do not use it when
- Things sit side by side: that is a Row.
- Columns must line up across rows: that is a Grid or Columns.
For everyone
- It only lays things out: reading order is the order in the code, so keep the code in the order a person reads.
Props
| Stack | Type | Default |
|---|---|---|
as | ElementType | div |
className | string | |
gap | Gap | |
id | string | |
style | CSSProperties |