Components

Box

Styling-capable universal container — foundation building block for all components

Overview

Box is the foundation building block of the design system. It provides styling capabilities to HTML elements while maintaining maximum flexibility.

Box is: a stylable <div> that can render as any HTML element.

  • Minimal — No built-in layout logic or predefined styles
  • Flexible — Render as any HTML element via the as prop
  • Universal — Base layer for all other components (Stack, Card, Button, etc.)
  • Unopinionated — Everything is controlled by the user

When to Use

Use Box when:

  • You need a simple wrapper or container
  • You need semantic HTML (as="section", as="article", as="nav")
  • You're building a custom component from scratch
  • You need maximum control with minimal abstraction

Consider alternatives when:

  • You need vertical/horizontal stacking → Use Stack or Inline
  • You need center alignment → Use Center
  • You're building a card → Use the Card component
  • You need button behavior → Use the Button component

If there's a specialized component for your use case, use it. Box is for everything else.

Box vs Other Components

ComponentPurposeBuilt on
BoxUniversal container-
StackVertical/horizontal layoutBox + flex logic
InlineHorizontal layoutBox + flex(row)
CenterCenter alignmentBox + centering
CardCard-styled containerBox + card styles

All components inherit Box's capabilities while adding specific behavior or styles.

Props

PropTypeDefaultDescription
asElementType'div'HTML element to render
childrenReactNode-Child elements
displaystring-CSS display
flexDirectionstring-Flex direction
alignItemsstring-Flex alignment
justifyContentstring-Flex justification
gapstring-Gap (space token)
pstring-Padding (space token)
pxstring-Horizontal padding
pystring-Vertical padding
mstring-Margin
wstring-Width
hstring-Height
maxWstring-Max width
bgstring-Background color (color token)
roundedstring-Border radius (radius token)
borderstring-Border
borderColorstring-Border color
borderStylestring-Border style
positionstring-CSS position
shadowstring-Shadow (dropShadow token)
classNamestring-Additional CSS class
styleCSSProperties-Inline styles

Usage

import { Box } from '@illog/ui'
 
// Basic usage
<Box p="400" bg="bgDefaultDefault" rounded="200">
  Content
</Box>
 
// Semantic HTML
<Box as="section" p="600">
  <Box as="article" p="400" shadow="200">
    Article content
  </Box>
</Box>
 
// Flex layout
<Box display="flex" gap="300" alignItems="center">
  <Icon name="check" />
  <Text>Done</Text>
</Box>
  • Stack — Vertical or horizontal layout with consistent spacing
  • Inline — Horizontal layout (row-direction optimized version of Stack)
  • Center — Center alignment
  • Card — Card-styled container