Overview
The Container component provides consistent content width, padding, and centering across your application. It’s the foundation for page layouts and helps maintain readable line lengths.Basic Usage
Sizes
Containers come in multiple sizes to accommodate different content needs:- Small
- Medium
- Large
- XL
- Full
The default size is
lg if not specified.Padding
Control the horizontal padding of the container:Centering
By default, containers are centered. You can disable this:Fluid Container
Create a container that maintains padding but has no max-width:Props
string
default:"lg"
Container max-width:
sm (640px), md (768px), lg (1024px), xl (1280px), or fullstring
default:"md"
Horizontal padding:
none, sm, md, or lgboolean
default:"true"
Whether to center the container horizontally
boolean
default:"false"
If true, removes max-width while keeping padding
ReactNode
required
The content to display inside the container
string
Additional CSS class names to apply
string
default:"'div'"
HTML element to render:
div, main, section, article, etc.TypeScript Interface
Layout Examples
Basic Page Layout
Article Layout
Dashboard Layout
Nested Containers
Full Width Section with Padded Content
Responsive Behavior
Containers automatically adjust their padding on smaller screens:- Desktop: Full padding as specified
- Tablet: Slightly reduced padding
- Mobile: Minimal padding to maximize screen space
Best Practices
-
Choose the right size: Use
smfor articles,mdfor standard pages,lgfor applications, andxlfor dashboards - Consistent usage: Use the same container size throughout similar pages for visual consistency
-
Nested sections: Wrap full-width colored sections around containers for visual variety:
-
Semantic HTML: Use the
asprop to render semantic elements (main,article,section) for better accessibility
Accessibility
- Uses semantic HTML elements when specified with
asprop - Maintains proper document structure
- Ensures content remains accessible and readable at all viewport sizes
- Provides consistent spacing for better visual hierarchy