VisorVisor
ComponentsLayout

Box

Universal layout wrapper for padding, margin, background, border, and border-radius via Visor design tokens.

npx visor add box

Why Box?

Box closes the gap between Visor's typed token system and ad-hoc Tailwind utility classes like p-4 bg-white rounded-lg. Every spacing, surface, border, and radius prop accepts only Visor token names — off-system values like padding="17px" are TypeScript errors. Token changes propagate automatically.

Reach for Box whenever you'd otherwise write inline padding/margin/background utilities. For arranging children, compose Stack, Inline, or Grid inside.

Padding

Padding md

Background + Border

Subtle surface with default border

Responsive Padding

The padding, paddingX, paddingY, edge-padding, and margin props all accept a responsive { base, sm, md, lg, xl } map for breakpoint-aware spacing.

<Box padding={{ base: "sm", md: "lg", xl: "2xl" }}>
  Responsive padding
</Box>

Polymorphic as

<Box as="section" padding="lg" bg="card">
  Renders a <section>
</Box>

Installation

npx visor add box

This copies two files into your project:

  • components/ui/box/box.tsx — the component
  • components/ui/box/box.module.css — the styles

API Reference

BoxProps

PropTypeDefaultDescription
askeyof React.JSX.IntrinsicElements'div'HTML element to render.
paddingSpacingToken | ResponsiveProp<SpacingToken>Shorthand padding on all sides. Token-named — off-system values are TypeScript errors.
paddingXSpacingToken | ResponsiveProp<SpacingToken>Padding on the X axis (overrides padding for left/right).
paddingYSpacingToken | ResponsiveProp<SpacingToken>Padding on the Y axis (overrides padding for top/bottom).
paddingTop / paddingRight / paddingBottom / paddingLeftSpacingToken | ResponsiveProp<SpacingToken>Padding on a single edge.
margin / marginX / marginY / margin{Top,Right,Bottom,Left}SpacingToken | ResponsiveProp<SpacingToken>Margin shorthand and per-axis/edge overrides.
bgSurfaceTokenToken-named background surface (e.g. 'card', 'subtle', 'muted', 'popover', 'accent-subtle').
borderboolean | BorderTokenWhen true uses --border-default; when a token name (e.g. 'error', 'strong') uses that border color.
borderRadiusRadiusTokenToken-named border radius ('none' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | 'full').

The component also accepts all standard HTML attributes for the rendered element.