Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Layout & primitives

Box

Free2.2 KB gzipped

Box: the polymorphic base building block. Renders as (default div) with token-based spacing, surfaces, tints, radius, shadow, and border.

Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · No keyboard interaction of its own · Full report

Import

tsx
import { Box } from "@vjdesigns/vjdesigns-ui";

Importing only Box adds about 2.2 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.

Examples

Surfaces

surface, tone, radius, shadow and border style a box with tokens, so it follows the theme.

Raised

Sunken

Primary soft

Success solid

tsx
import { Box, Flex, Text } from "@vjdesigns/vjdesigns-ui";

export function Surfaces() {
  return (
    <Flex gap={4} wrap="wrap" justify="center">
      <Box surface="raised" shadow="md" radius="lg" p={5}>
        <Text weight="semibold">Raised</Text>
      </Box>
      <Box surface="sunken" radius="lg" p={5} border>
        <Text weight="semibold">Sunken</Text>
      </Box>
      <Box tone="primary" radius="lg" p={5}>
        <Text weight="semibold" tone="inherit">
          Primary soft
        </Text>
      </Box>
      <Box tone="success" variant="solid" radius="lg" p={5}>
        <Text weight="semibold" tone="inherit">
          Success solid
        </Text>
      </Box>
    </Flex>
  );
}

Spacing and element

Spacing props (p, px, m, mt…) take steps of the spacing scale. as changes the element.

px={4} py={2} mb={4}

This section has p={8}: 2rem of padding on every side.

tsx
import { Box, Text } from "@vjdesigns/vjdesigns-ui";

export function SpacingAndElement() {
  return (
    <Box as="section" aria-label="Spacing demo" border="strong" radius="xl" p={8} style={{ width: "100%", maxWidth: "26rem" }}>
      <Box tone="accent" radius="md" px={4} py={2} mb={4}>
        <Text size="sm" weight="semibold" tone="inherit">
          px={"{4}"} py={"{2}"} mb={"{4}"}
        </Text>
      </Box>
      <Text tone="muted">This section has p={"{8}"}: 2rem of padding on every side.</Text>
    </Box>
  );
}

Accessibility

Box is a <div> unless you say otherwise. Give it the element that matches its role with as (section, aside, nav…) so the structure comes from HTML, and name a region with the heading inside it.

Shipping address

Ana Ruiz, 12 Calle Mayor, Madrid

tsx
import { Box, Text, Heading } from "@vjdesigns/vjdesigns-ui";

export function Accessibility() {
  return (
    <Box as="section" aria-labelledby="box-a11y-title" surface="raised" border radius="lg" p={5} style={{ width: "100%", maxWidth: "26rem" }}>
      <Heading id="box-a11y-title" level={3} size="md">
        Shipping address
      </Heading>
      <Text tone="muted">Ana Ruiz, 12 Calle Mayor, Madrid</Text>
    </Box>
  );
}

Translated

Alignment values like textAlign="start" are logical, so in Arabic "start" is the right edge. Your own styles mirror too when they use logical properties such as padding-inline-start.

عنوان الشحن

شارع النيل 12، القاهرة

tsx
import { Box, Text, LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";

export function Translated() {
  return (
    <LocaleProvider locale="ar" messages={ar}>
      <Box surface="raised" border radius="lg" p={5} textAlign="start" style={{ width: "100%", maxWidth: "26rem" }}>
        <Text weight="semibold">عنوان الشحن</Text>
        <Text tone="muted">شارع النيل 12، القاهرة</Text>
      </Box>
    </LocaleProvider>
  );
}

Usage notes

Box adds no semantics. When rendering an interactive element (as="a" with href, as="button"), you own its accessible name, keyboard behavior, and states; prefer the dedicated components.

API reference

Box

Box props
PropTypeDefault
surface

Neutral surface background, paired with --color-text. Ignored when tone is set.

"bg""surface""raised""sunken"—
tone

Semantic tint. soft uses --color-{tone}-subtle with --color-{tone}-subtle-text; solid uses --color-{tone} with --color-on-{tone}. neutral maps to the sunken surface (soft) or inverted text colors (solid).

"neutral""primary""accent""success""warning""danger""info"—
variant

How tone is applied. Only used when tone is set.

"soft""solid""soft"
radius

Corner rounding (--radius-*).

"none""xs""sm""md""lg""xl""2xl""pill"—
shadow

Soft drop shadow (--shadow-*).

"none""xs""sm""md""lg""xl"—
border

Border. true or "default" uses --color-border (decorative, low contrast); "strong" uses --color-border-strong, which meets 3:1 for meaningful boundaries.

falsetrue"strong""default"—
display

CSS display.

"block""inline""inline-block""flex""inline-flex""grid""inline-grid""contents""none"—
position

CSS position.

"static""relative""absolute""fixed""sticky"—
overflow

CSS overflow.

"visible""hidden""auto""scroll""clip"—
textAlign

Text alignment (logical: start/end follow writing direction).

"start""center""end""justify"—
p

Padding on all sides (--space-* step).

SpaceValue—
px

Horizontal padding (inline start and end). Overrides p.

SpaceValue—
py

Vertical padding (block start and end). Overrides p.

SpaceValue—
pt

Top padding. Overrides p and py.

SpaceValue—
pr

End padding (right in left-to-right, left in right-to-left). Overrides p and px.

SpaceValue—
pb

Bottom padding. Overrides p and py.

SpaceValue—
pl

Start padding (left in left-to-right, right in right-to-left). Overrides p and px.

SpaceValue—
m

Margin on all sides (--space-* step or "auto").

MarginValue—
mx

Horizontal margin. Overrides m.

MarginValue—
my

Vertical margin. Overrides m.

MarginValue—
mt

Top margin. Overrides m and my.

MarginValue—
mr

End margin (right in left-to-right). Overrides m and mx.

MarginValue—
mb

Bottom margin. Overrides m and my.

MarginValue—
ml

Start margin (left in left-to-right). Overrides m and mx.

MarginValue—
width

CSS width. Numbers are px. On a media element (as="img", video, canvas, svg, iframe) a number is also set as the HTML width attribute, so the browser can reserve its aspect ratio.

SizeValue—
height

CSS height. Numbers are px. On a media element a number is also the HTML height attribute.

SizeValue—
minWidth

CSS min-width. Numbers are px.

SizeValue—
maxWidth

CSS max-width. Numbers are px.

SizeValue—
minHeight

CSS min-height. Numbers are px.

SizeValue—
maxHeight

CSS max-height. Numbers are px.

SizeValue—
as

Element or component to render.

ElementType"div"

See what changed in each version in the Changelog.

Accessibility report

Box targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.

axe-core audit (live)

Running accessibility audit

Checking the examples above…

Lighthouse audit

Light mode

Score 100

35 passed · 0 failed · 30 not applicable · 10 to check by hand

Dark mode

Score 100

35 passed · 0 failed · 30 not applicable · 10 to check by hand

Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.

Built-in behavior

Keyboard

Not focusable, so there's no keyboard interaction of its own.

Roles and states

Roles and states
ElementRoleStates and properties
<div>, or the element in asNative role of that elementUse as="section" with a name for a landmark

Manual checks

Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.

Manual accessibility checks
CheckWhat to testWCAG 2.2
KeyboardEvery action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck.2.1.1 (A), 2.1.2 (A)
FocusFocus moves in a logical order, is always visible, and isn't hidden behind sticky headers.2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA)
Screen readersNames, roles and states are announced correctly, and status changes are announced without moving focus.1.3.1 (A), 4.1.2 (A), 4.1.3 (AA)
ColorMeaning never depends on color alone; your own colors meet contrast in both modes.1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA)
Zoom and reflowAt 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed.1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA)
Pointer targetsClick and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap.2.5.8 (AA), 2.5.5 (AAA)
MotionAnimations respect the reduced-motion setting.2.3.3 (AAA)