Skip to main content

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:
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 full
string
default:"md"
Horizontal padding: none, sm, md, or lg
boolean
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
Use smaller container sizes (sm or md) for content-focused pages like blog posts and documentation to improve readability.
Use larger container sizes (xl or full) for application interfaces and dashboards that need more horizontal space.

Best Practices

  1. Choose the right size: Use sm for articles, md for standard pages, lg for applications, and xl for dashboards
  2. Consistent usage: Use the same container size throughout similar pages for visual consistency
  3. Nested sections: Wrap full-width colored sections around containers for visual variety:
  4. Semantic HTML: Use the as prop to render semantic elements (main, article, section) for better accessibility

Accessibility

  • Uses semantic HTML elements when specified with as prop
  • Maintains proper document structure
  • Ensures content remains accessible and readable at all viewport sizes
  • Provides consistent spacing for better visual hierarchy