Playground

Box

A div with padding and a thin border mapped to the spacing tokens.

  • Built on native elements
  • A plain element; adds no roles. Use asChild to render a landmark such as section.
  • Styles in one file: box.css

Import

import '@monoline/css';
import {Box} from '@monoline/react';

Not installed yet? Pick a route.

Copies the source and its styles into your project.

npx monoline add box

Usage

import {Box} from '@monoline/react';

<Box padding={5} border>A bordered box with step 5 padding.</Box>

Examples

Padding and border

One side, as a section

Props

BoxProps

PropTypeDefaultDescription
paddingStep–Padding on all sides: a step on the spacing scale (1 = --s1 up to 9).
paddingXStep–Horizontal padding (left and right) as a step 1 to 9 on the spacing scale; overrides `padding` on that axis.
paddingYStep–Vertical padding (top and bottom) as a step 1 to 9 on the spacing scale; overrides `padding` on that axis.
borderboolean | "start" | "top" | "right" | "bottom" | "left" | "end"–A thin rule on every side (`true`) or on one side.
asChildboolean–Render the child (a `section`, `aside`, `li`) with the box styles.

Data Attributes

State is exposed through attributes. Style it with these selectors, not with class toggles.

AttributeStylesheet
[data-border]box.css
[data-border="bottom"]box.css
[data-border="end"]box.css
[data-border="left"]box.css
[data-border="right"]box.css
[data-border="start"]box.css
[data-border="top"]box.css

CSS classes

ClassStylesheet
.boxbox.css
.box-borderbox.css

Customization

Style it with the kit's tokens in your own CSS, loaded after @monoline/css. Prefer the attributes above over extra classes. See Theming for every token.

app.css
.box {
  border-color: var(--accent);
}
.box[data-border] {
  background: var(--wash);
}

Accessibility

  • A plain element; adds no roles. Use asChild to render a landmark such as section.