Stack
Lays out its children in a column or a row, spaced by a gap from the spacing scale.
<arc-stack>Overview
Stack lays out its children in a column or a row with a gap from the spacing scale. You set direction, gap, align and justify as attributes in place of writing flexbox CSS.
The host element is the flex container, and render() returns a bare <slot>, so Stack adds no DOM nodes of its own. With no attributes it's a column with a md gap and children stretched to its width.
wrap lets a row wrap onto more lines. Use it for a set of tags or small cards. For columns that line up across rows, use CSS Grid.
Guidelines
Do
- Combine `direction="horizontal"` with `justify="between"` for a toolbar-style row
- Nest a horizontal stack inside a vertical one for rows within a column
- Space children with `gap`, not margins
Don't
- Don't use it for two-dimensional layouts where columns must line up. Use CSS Grid
- Don't use `gap="xs"` between major sections. Keep it for tight clusters such as an icon and its label
Features
- Gap scale: `xs`, `sm`, `md`, `lg`, `xl` and `2xl`, mapped to the `--space-*` tokens
- `align` takes `start`, `center`, `end` or `stretch`
- `justify` takes `start`, `center`, `end`, `between` or `around`
Preview
Usage
<arc-stack direction="vertical" gap="md">
<arc-text>Item one</arc-text>
<arc-text>Item two</arc-text>
<arc-text>Item three</arc-text>
</arc-stack>
<arc-stack direction="horizontal" gap="sm" align="center" justify="between">
<arc-button variant="ghost">Cancel</arc-button>
<arc-button>Save</arc-button>
</arc-stack>import { Stack, Text, Button } from '@arclux/arc-ui-react';
export default function Example() {
return (
<>
<Stack direction="vertical" gap="md">
<Text>Item one</Text>
<Text>Item two</Text>
</Stack>
<Stack direction="horizontal" gap="sm" align="center" justify="between">
<Button variant="ghost">Cancel</Button>
<Button>Save</Button>
</Stack>
</>
);
}<script setup>
import { Stack, Text } from '@arclux/arc-ui-vue';
</script>
<template>
<Stack direction="vertical" gap="md">
<Text>Item one</Text>
<Text>Item two</Text>
</Stack>
</template><script>
import { Stack, Text } from '@arclux/arc-ui-svelte';
</script>
<Stack direction="vertical" gap="md">
<Text>Item one</Text>
<Text>Item two</Text>
</Stack>import { Component } from '@angular/core';
import { Stack, Text } from '@arclux/arc-ui-angular';
@Component({
imports: [Stack, Text],
template: `
<arc-stack direction="vertical" gap="md">
<arc-text>Item one</arc-text>
<arc-text>Item two</arc-text>
</arc-stack>
`,
})
export class MyComponent {}import { Stack, Text } from '@arclux/arc-ui-solid';
export default function Example() {
return (
<Stack direction="vertical" gap="md">
<Text>Item one</Text>
<Text>Item two</Text>
</Stack>
);
}import { Stack, Text } from '@arclux/arc-ui-preact';
export default function Example() {
return (
<Stack direction="vertical" gap="md">
<Text>Item one</Text>
<Text>Item two</Text>
</Stack>
);
}<!-- Auto-generated by @arclux/prism — do not edit manually -->
<!-- arc-stack — requires stack.css + tokens.css (or arc-ui.css) -->
<div class="arc-stack">
Stack
</div><!-- Auto-generated by @arclux/prism — do not edit manually -->
<!-- arc-stack — self-contained, no external CSS needed -->
<div class="arc-stack" style="display: flex; flex-direction: column; gap: 16px; align-items: stretch; justify-content: flex-start">
Stack
</div>API
direction'vertical' | 'horizontal''vertical'- Flex direction: vertical is column, horizontal is row
gap'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl''md'- Gap between children, maps to --space-* tokens
align'start' | 'center' | 'end' | 'stretch''stretch'- Cross-axis alignment (align-items)
justify'start' | 'center' | 'end' | 'between' | 'around''start'- Main-axis alignment (justify-content)
wrapbooleanfalse- Enable flex-wrap for responsive wrapping