Box
A div with padding and a thin border mapped to the spacing tokens.
SourceStyles source@monoline/react 0.4.0Markdown for AI toolsstable
- 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
| Prop | Type | Default | Description |
|---|---|---|---|
padding | Step | – | Padding on all sides: a step on the spacing scale (1 = --s1 up to 9). |
paddingX | Step | – | Horizontal padding (left and right) as a step 1 to 9 on the spacing scale; overrides `padding` on that axis. |
paddingY | Step | – | Vertical padding (top and bottom) as a step 1 to 9 on the spacing scale; overrides `padding` on that axis. |
border | boolean | "start" | "top" | "right" | "bottom" | "left" | "end" | – | A thin rule on every side (`true`) or on one side. |
asChild | boolean | – | 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.
| Attribute | Stylesheet |
|---|---|
[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
| Class | Stylesheet |
|---|---|
.box | box.css |
.box-border | box.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.