Examples

Vertical

Preview
First
Second
Third
Example.tsx
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.

Preview
Account
Billing
Security
Example.tsx
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

Preview

Invoices

128 total
Example.tsx
import { 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

Stack props
PropTypeDefault
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
booleanfalse
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.