Skip to content

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'

On this page
  1. A settings form
  2. In Astro
  3. When to use it
  4. For everyone
  5. Props

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.

A static page uses the same helpers, without JavaScript.

Gap 3 is var(--s-3), 0.75rem.

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-top between 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

StackTypeDefault
as ElementType div
className string
gap Gap
id string
style CSSProperties
  1. A settings form
  2. In Astro
  3. When to use it
  4. For everyone
  5. Props

    Search pages, sections and terms