structyl

Box

stable

A low-level layout primitive.

Basic usage

Box

Examples

As a layout wrapper

Use Box when you want the smallest possible styled layout primitive and full control through className.

Project status

Build checks are running for the release branch.

asChild composition

Pass asChild when Box should style another element, such as a semantic section.

Semantic section rendered through Box.

Supported props

Use display, spacing shortcuts, asChild and className for system-style composition.

Grid display with padding 4

Features

  • Renders a div by default.
  • Supports asChild composition.

Installation

bash
pnpm dlx structyl add box

API Reference

Box

Low-level layout wrapper.

PropTypeDefault
display'block' | 'inline' | 'inline-block' | 'flex' | 'inline-flex' | 'grid' | 'contents'

Display utility applied to the root.

padding0 | 1 | 2 | 3 | 4 | 5 | 6 | 8

Tokenized padding shortcut.

margin0 | 1 | 2 | 3 | 4 | 5 | 6 | 8

Tokenized margin shortcut.

asChildboolean

Merge props onto the immediate child instead of rendering the default element.

false
classNamestring

Additional Tailwind classes merged with the component defaults.

Box | structyl