Description
The Box component is a versatile container component that provides a foundation for building layouts. It’s a simple wrapper around a div element with consistent box-sizing behavior, allowing you to pass any standard HTML attributes and custom styling.Props
Box extends all standard HTML div attributes and accepts the following props:The content to be rendered inside the Box component
Additional CSS class names to apply to the Box
A ref object to access the underlying div element
All standard HTML div attributes are supported including:
id- Element IDrole- ARIA role attributearia-label- Accessibility labelaria-labelledby- ID of the labeling elementdata-*- Data attributes- Event handlers (
onClick,onMouseEnter, etc.)
Usage examples
Basic usage
With custom className
With multiple children
Nested boxes
With ref
With ARIA attributes
With dynamic children
Styling notes
The Box component applies a single CSS property by default:box-sizing: border-box- Ensures padding and border are included in the element’s total width and height
className prop or inline styles.