LayoutStack
Searchastronomic.dev# Stack
To set blocks one under another with even space between them, like a heading, a text and a button.
Static: no JavaScript.
## Usage
```astro
import Stack from "@astronomic-dev/ui/components/Stack.astro";
```
## Examples
### A heading, a text and an action
```astro
---
import Button from "@astronomic-dev/ui/components/Button.astro";
import Stack from "@astronomic-dev/ui/components/Stack.astro";
---
<Stack class="max-w-md items-start">
<Stack gap="item">
<h3 class="m-0 text-xl font-semibold">Have a project in mind?</h3>
<p class="m-0 text-muted">Tell us what you need and when. We answer within two business days.</p>
</Stack>
<Button href="#contact">Get in touch</Button>
</Stack>
```
### Gaps
item for close pairs, blocks between blocks, section between groups.
```astro
---
import Stack from "@astronomic-dev/ui/components/Stack.astro";
const gaps = ["item", "blocks", "section"] as const;
---
<div class="grid gap-6 sm:grid-cols-3">
{
gaps.map((gap) => (
<Stack gap={gap}>
<p class="m-0 rounded-card bg-surface-2 p-3 text-sm text-muted">gap="{gap}"</p>
<p class="m-0 rounded-card bg-surface-2 p-3 text-sm text-muted">Second</p>
<p class="m-0 rounded-card bg-surface-2 p-3 text-sm text-muted">Third</p>
</Stack>
))
}
</div>
```
## Props
### Stack
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `as` | `HTMLTag` | `"div"` | The element to render, such as ul or article. |
| `gap` | `"item" \| "blocks" \| "section"` | `"blocks"` | The space between children: a spacing role, set by the preset. |
| `class` | `string` | None | More classes, merged with cn(), so yours win on conflicts. |
| Slot | Description |
| --- | --- |
| `default` | The blocks, one under another, each as wide as the Stack. |
Any other attribute goes on the rendered element.
## Accessibility
- Renders a plain <div> with no role, so it adds nothing for a screen reader.
- It never reorders children: the reading order is the source order.
- For a list of items, use as="ul" with <li> children, and role="list" if you remove the bullets.
Stack
FreeTo set blocks one under another with even space between them, like a heading, a text and a button.
- File
- Stack.astro
- Group
- Layout
- Kind
- Static: no JavaScript
- Examples
- 2
Examples
Drag the orange handle to set the width. Frames get real breakpoints.
- Static
- Interactive
- Framed
A heading, a text and an action
Have a project in mind?
Tell us what you need and when. We answer within two business days.
Force statemain.astro
examples/stack/main.astro
---
import Button from "@astronomic-dev/ui/components/Button.astro";
import Stack from "@astronomic-dev/ui/components/Stack.astro";
---
<Stack class="max-w-md items-start">
<Stack gap="item">
<h3 class="m-0 text-xl font-semibold">Have a project in mind?</h3>
<p class="m-0 text-muted">Tell us what you need and when. We answer within two business days.</p>
</Stack>
<Button href="#contact">Get in touch</Button>
</Stack>Gaps
item for close pairs, blocks between blocks, section between groups.
gap="item"
Second
Third
gap="blocks"
Second
Third
gap="section"
Second
Third
Force stategaps.astro
examples/stack/gaps.astro
---
import Stack from "@astronomic-dev/ui/components/Stack.astro";
const gaps = ["item", "blocks", "section"] as const;
---
<div class="grid gap-6 sm:grid-cols-3">
{
gaps.map((gap) => (
<Stack gap={gap}>
<p class="m-0 rounded-card bg-surface-2 p-3 text-sm text-muted">gap="{gap}"</p>
<p class="m-0 rounded-card bg-surface-2 p-3 text-sm text-muted">Second</p>
<p class="m-0 rounded-card bg-surface-2 p-3 text-sm text-muted">Third</p>
</Stack>
))
}
</div>Minimal · Light