Layout
Box
A semantic wrapper with an optional responsive display, for show/hide and landmarks.
Purpose
Box renders one element with no styling except an optional responsive display. Use it to pick a
semantic element, to apply asChild, or to show and hide content per breakpoint without media
queries in your CSS.
Import
import { Box } from "@neshel-ui/layout";Usage
Preview: box-display
Always visible
Visible from md
import { Box, Inline } from "@neshel-ui/layout";
import { Tile } from "./_tile";
/** Box adds semantics and a responsive display without extra styling. */
export default function BoxDisplay() {
return (
<Inline space="3" align="center">
<Box as="section" aria-label="Always visible">
<Tile>Always visible</Tile>
</Box>
{/* Hidden below md, block from md (resize the window to see it). */}
<Box display={{ base: "none", md: "block" }}>
<Tile>Visible from md</Tile>
</Box>
</Inline>
);
}API
BoxProps
| Prop | Type | Default | Description |
|---|---|---|---|
| as | LayoutElement | — | — |
| asChild | boolean | — | — |
| display | Responsive<BoxDisplay> | — | — |
| ref | Ref<HTMLElement> | — | — |
Also accepts the props of: React DOM attributes.
BoxDisplay
type BoxDisplay = "none" | "block" | "inline" | "inline-block"- Default element:
div.asaccepts the layout element list. displayvalues:none,block,inline,inline-block— responsive. Withoutdisplay, the element keeps its native display.
Accessibility
display="none" removes content from the accessibility tree at that width, just like CSS. Do not hide
the only copy of essential content at small widths.
Common mistakes
- Using
Boxfor spacing: it has nospaceprop — useStackorInline. - Expecting
display="flex": useFlex, which also manages direction and alignment.