Layout
Stack
Flexbox layouts with consistent token gaps: Stack and VStack (vertical), HStack (horizontal, centred), Flex (no defaults) and Spacer.
import { Stack, HStack, VStack, Flex, Spacer } from '@reactloom/ui';Examples
Vertical
First
Second
Third
import { Box, Stack } from '@reactloom/ui';
const Item = ({ children }: { children: string }) => (
<Box padding="3" background="subtle" radius="md" bordered>{children}</Box>
);
export default function Example() {
return (
<Stack gap="3" style={{ width: '100%', maxWidth: 360 }}>
<Item>First</Item>
<Item>Second</Item>
<Item>Third</Item>
</Stack>
);
}Responsive direction
Column on small screens, row from md — pure CSS, SSR-safe.
Account
Billing
Security
import { Box, Stack } from '@reactloom/ui';
const Item = ({ children }: { children: string }) => (
<Box padding="3" background="subtle" radius="md" bordered style={{ flex: 1 }}>{children}</Box>
);
export default function Example() {
// Column on small screens, row from 768 px — resize the window to see it switch.
return (
<Stack direction={{ base: 'column', md: 'row' }} gap={{ base: '2', md: '4' }} style={{ width: '100%' }}>
<Item>Account</Item>
<Item>Billing</Item>
<Item>Security</Item>
</Stack>
);
}Toolbar with Spacer
Invoices
128 totalimport { Button, HStack, Spacer, Text } from '@reactloom/ui';
import { Plus } from 'lucide-react';
export default function Example() {
return (
<HStack as="header" style={{ width: '100%' }}>
<Text weight="semibold" size="lg">Invoices</Text>
<Text as="span" tone="muted" size="sm">128 total</Text>
<Spacer />
<Button variant="secondary" size="sm">Export</Button>
<Button size="sm" startIcon={<Plus />}>New invoice</Button>
</HStack>
);
}API reference
| Prop | Type | Default |
|---|---|---|
direction | Responsive<'row' | 'column' | 'row-reverse' | 'column-reverse'> | 'column' |
gap | Responsive<Space> | '3' |
align | Responsive<'start' | 'center' | 'end' | 'stretch' | 'baseline'> | — |
justify | Responsive<'start' | 'center' | 'end' | 'between' | 'around' | 'evenly'> | — |
wrap · inline | boolean | false |
as | LayoutElement | 'div' |
Accessibility
- Avoid *-reverse directions when order carries meaning: screen readers follow DOM order.
Usage guidelines
Do
- Use gap instead of margins on children.
Don’t
- Don’t nest stacks only to add spacing — use gap.