Examples

Basic

Preview

Scheduled maintenance

Sunday 02:00–03:00 UTC. Reports may be delayed.

Example.tsx
import { Box, Text } from '@reactloom/ui';

export default function Example() {
  return (
    <Box as="section" aria-label="Notice" padding="5" background="subtle" radius="lg" bordered style={{ maxWidth: 420 }}>
      <Text weight="semibold">Scheduled maintenance</Text>
      <Text tone="muted" size="sm">Sunday 02:00–03:00 UTC. Reports may be delayed.</Text>
    </Box>
  );
}

Responsive padding

Responsive props take a value or a mobile-first breakpoint map.

Preview

Padding grows from 12 px to 32 px at the md breakpoint.

Example.tsx
import { Box, Text } from '@reactloom/ui';

export default function Example() {
  return (
    <Box paddingX={{ base: '3', md: '8' }} paddingY={{ base: '3', md: '6' }} background="surface" radius="md" bordered>
      <Text>Padding grows from 12 px to 32 px at the md breakpoint.</Text>
    </Box>
  );
}

API reference

Box props
PropTypeDefault
as
section, article, aside, main, header, footer, nav, ul, li, span…
LayoutElement'div'
padding · paddingX · paddingY
Space tokens 0–16.
Responsive<Space>—
background
'canvas' | 'surface' | 'subtle' | 'muted'—
radius
'none' | 'sm' | 'md' | 'lg' | 'full'—
bordered
booleanfalse

Customization

Extracted from the component’s source on every build, so it matches the code. How the layers fit together is explained in Customization.

State attributes

Target these in your CSS to style states without depending on class names.

AttributeValues
[data-background]canvas · surface · subtle · muted
[data-bordered]present when on
[data-radius]none · sm · md · lg · full

Theme tokens it reads

--pl-color-bg-canvas --pl-color-bg-muted --pl-color-bg-subtle --pl-color-bg-surface --pl-color-border-default --pl-radius-full --pl-radius-lg --pl-radius-md --pl-radius-none --pl-radius-sm

Accessibility

  • No implicit role — choose a semantic element with as.

Usage guidelines

Do

  • Prefer Stack/Grid for arranging children.

Don’t

  • Don’t use Box with a click handler — use a Button.