Skip to content

Box

Box

Category: Layout & primitives

A neutral container. Use it when you need spacing without semantics.

<Box p={4}>16px padding all sides</Box>
<Box px={6} py={4}>24px inline, 16px block</Box>
<Box p="2rem">Raw CSS still works</Box>

Install: @helix-ui/core

import { Box } from '@helix-ui/core';

status: stable · since: 0.1.0

Tags: primitive, container, spacing, utility

Anatomy

[ <children> ] ← unstyled container with padding/margin shorthands

Layout

  • display — block
  • width — auto
  • height — auto
  • intrinsicSize — content size; tunable padding/margin via props
  • stackable — true
  • fullBleed — false

Visual

A presentational <div> with token-aware padding (p, px, py, …) and margin shorthands. No background, border, or radius by default — strictly a layout primitive.

Props

NameTypeDefaultDescription
pnumber | string—Padding on all sides. Numeric input → space.N token; string passes through as raw CSS.
pxnumber | string—Inline (left+right) padding.
pynumber | string—Block (top+bottom) padding.
ptnumber | string—Block-start padding — the top edge in horizontal writing modes.
pbnumber | string—Block-end padding.
psnumber | string—Inline-start padding — left in LTR, right in RTL.
penumber | string—Inline-end padding.
mnumber | string—Margin on all sides.
mxnumber | string—Inline margin.
mynumber | string—Block margin.
mtnumber | string—Block-start margin — the top edge in horizontal writing modes.
mbnumber | string—Block-end margin.
msnumber | string—Inline-start margin — left in LTR, right in RTL.
menumber | string—Inline-end margin.
...restHTMLAttributes<HTMLDivElement>—Native div attributes.

Tokens used

space.0, space.1, space.2, space.3, space.4, space.5, space.6, space.8, space.10, space.12, space.16, space.20, space.24

Accessibility

Notes

  • Box is presentational. Use a semantic element where possible (<section>, <article>, etc.).

Composes with

ComponentRelationNote
StackalternativeUse Stack when you want a flex column/row of children.
FlexalternativeUse Flex for explicit flexbox layout.
GridalternativeUse Grid for 2-D layout.

Prompt examples

These are the AI prompt → JSX mappings used by the helix-ui prompt DSL and integrations like Cursor / Claude Code.

pad a section

“add 24px of padding around this group”

<Box p={6}>{children}</Box>

horizontal rule of margin

“add top margin”

<Box mt={4}>{children}</Box>