The Box component is a versatile container component that provides multiple variants for different use cases. Each variant has unique styling and behavior to suit various design needs.
import { Box } from '@dashflowx/core'export default function BoxExample() {return (<Boxvariant="default"size="md"className="p-4 bg-gray-100 rounded-lg"boxItem="<p>This is content inside a Box component.</p>"/>)}
Preview:
This is content inside a Box component.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | string | 'default' | The visual variant of the box |
size | string | 'md' | The size of the box |
className | string | - | Additional CSS classes to apply to the box |
boxItem | string | - | HTML content to render inside the box |
No special styling, clean and minimal.
<Boxvariant="default"size="md"boxItem="<p>Simple default box with no special styling.</p>"/>
Simple default box with no special styling.
Centered layout with generous padding for page sections.
<Boxvariant="container"size="md"boxItem="<h3>Container Title</h3><p>Container variant with centered layout and padding.</p>"/>
Container Title
Container variant with centered layout and padding.
Elevated card design with shadow and hover effects.
<Boxvariant="card"size="md"boxItem="<h3 className='text-xl font-bold mb-2'>Card Title</h3><p>Card variant with shadow and hover effects.</p>"/>
Card Title
Card variant with shadow and hover effects.
Consistent vertical spacing between child elements.
<Boxvariant="spacing"size="md"boxItem="<div className='p-2 bg-blue-100 rounded'>First item</div><div className='p-2 bg-green-100 rounded'>Second item</div><div className='p-2 bg-yellow-100 rounded'>Third item</div>"/>
Horizontal layout with centered items and gap spacing.
<Boxvariant="flex"size="md"boxItem="<span className='px-3 py-1 bg-blue-500 text-white rounded'>Left</span><span className='px-3 py-1 bg-green-500 text-white rounded'>Right</span>"/>
2-column grid layout with gap spacing.
<Boxvariant="grid"size="md"boxItem="<div className='p-2 bg-blue-100 rounded text-center'>Grid 1</div><div className='p-2 bg-green-100 rounded text-center'>Grid 2</div><div className='p-2 bg-yellow-100 rounded text-center'>Grid 3</div><div className='p-2 bg-red-100 rounded text-center'>Grid 4</div>"/>
Adaptive padding that scales with screen size.
<Boxvariant="responsive"size="md"boxItem="<h4 className='font-semibold mb-2'>Responsive Box</h4><p>This variant adapts to different screen sizes.</p>"/>
Responsive Box
This variant adapts to different screen sizes.
Interactive design with border, cursor pointer, and hover effects.
<Boxvariant="interactive"size="md"boxItem="<div className='text-center'><span className='font-medium'>Click me!</span><br/><small>Hover to see effects</small></div>"/>
Hover to see effects
Colorful gradient background with enhanced shadow.
<Boxvariant="gradient"size="md"boxItem="<h3 className='text-xl font-bold mb-2'>Gradient Box</h3><p>Beautiful gradient background with enhanced styling.</p>"/>
Gradient Box
Beautiful gradient background with enhanced styling.
Smooth animations with hover effects and scaling.
<Boxvariant="animated"size="md"boxItem="<div className='text-center'><h3 className='font-bold mb-2'>Animated Box</h3><p>Hover to see animations!</p></div>"/>
Animated Box
Hover to see animations!
Minimal padding and small text for compact layouts.
<Boxvariant="default"size="sm"boxItem="<p className='text-sm'>Small size with minimal padding.</p>"/>
Small size with minimal padding.
Standard padding and text size for most use cases.
<Boxvariant="default"size="md"boxItem="<p>Medium size with standard padding.</p>"/>
Medium size with standard padding.
Generous padding and larger text for prominent content.
<Boxvariant="default"size="lg"boxItem="<p className='text-lg'>Large size with generous padding.</p>"/>
Large size with generous padding.
Maximum padding and largest text for hero sections.
<Boxvariant="default"size="xl"boxItem="<p className='text-xl'>Extra large size with maximum padding.</p>"/>
Extra large size with maximum padding.
<Boxvariant="card"size="lg"className="max-w-2xl mx-auto"boxItem="<div><h2 className='text-2xl font-bold mb-4 text-center'>Advanced Box</h2><div className='grid grid-cols-2 gap-4'><div className='p-3 bg-blue-50 rounded'><h3 className='font-semibold text-blue-800'>Feature 1</h3><p className='text-blue-600'>Description of feature 1</p></div><div className='p-3 bg-green-50 rounded'><h3 className='font-semibold text-green-800'>Feature 2</h3><p className='text-green-600'>Description of feature 2</p></div></div></div>"/>
Advanced Box
Feature 1
Description of feature 1
Feature 2
Description of feature 2
<Boxvariant="grid"size="md"className="bg-gray-50 p-6 rounded-xl"boxItem="<div className='p-3 bg-white rounded shadow hover:shadow-md transition-shadow cursor-pointer'><h4 className='font-medium text-gray-800'>Grid Item 1</h4><p className='text-sm text-gray-600'>Interactive content</p></div><div className='p-3 bg-white rounded shadow hover:shadow-md transition-shadow cursor-pointer'><h4 className='font-medium text-gray-800'>Grid Item 2</h4><p className='text-sm text-gray-600'>Interactive content</p></div><div className='p-3 bg-white rounded shadow hover:shadow-md transition-shadow cursor-pointer'><h4 className='font-medium text-gray-800'>Grid Item 3</h4><p className='text-sm text-gray-600'>Interactive content</p></div><div className='p-3 bg-white rounded shadow hover:shadow-md transition-shadow cursor-pointer'><h4 className='font-medium text-gray-800'>Grid Item 4</h4><p className='text-sm text-gray-600'>Interactive content</p></div>"/>
Grid Item 1
Interactive content
Grid Item 2
Interactive content
Grid Item 3
Interactive content
Grid Item 4
Interactive content
- Use
defaultfor simple containers - Use
containerfor page sections - Use
cardfor content cards - Use
spacingfor lists with consistent gaps - Use
flexfor horizontal layouts - Use
gridfor grid layouts - Use
responsivefor adaptive designs - Use
interactivefor clickable elements - Use
gradientfor eye-catching backgrounds - Use
animatedfor engaging interactions
- Use
smfor compact, dense layouts - Use
mdfor standard content spacing - Use
lgfor prominent, spacious content - Use
xlfor hero sections and large content areas
- Use the
boxItemattribute to pass HTML content - HTML content will be rendered inside the Box component
- Combine with
classNamefor additional styling - Use self-closing tags when using the
boxItemattribute
- Ensure sufficient color contrast
- Provide hover states for interactive variants
- Use semantic HTML in your boxItem content
