Layout
Box
The lowest-level layout element: token-based padding, background, border and radius on any HTML element.
import { Box } from '@reactloom/ui';Examples
Basic
Scheduled maintenance
Sunday 02:00–03:00 UTC. Reports may be delayed.
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.
Padding grows from 12 px to 32 px at the md breakpoint.
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
| Prop | Type | Default |
|---|---|---|
assection, article, aside, main, header, footer, nav, ul, li, span… | LayoutElement | 'div' |
padding · paddingX · paddingYSpace tokens 0–16. | Responsive<Space> | — |
background | 'canvas' | 'surface' | 'subtle' | 'muted' | — |
radius | 'none' | 'sm' | 'md' | 'lg' | 'full' | — |
bordered | boolean | false |
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.
| Attribute | Values |
|---|---|
[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.