Skip to content
Playground

Container

Constrains content width and provides responsive inline gutters.

Container establishes the horizontal reading boundary for a page or section. It fills the available width, centers itself, stops growing at a selected maximum width, and adds inline gutters so content does not touch the viewport edge.

It does not add vertical spacing, arrange children, or create a visual surface. Compose it with Section for page rhythm, Stack or Grid for child layout, and Box for elevation or decoration.

Quarterly review

Workspace activity

The section background spans the available width while Container keeps the content centered, readable, and clear of the viewport edge.

In this pattern, Section owns the full-width background and block padding. Container owns only the centered content measure and responsive inline gutters.

TSX
import { Container } from "@zentara-co/zenos-ui";

Without props, Container renders a div with four behaviors:

  • width: 100% lets it contract with its parent.
  • max-width: 64rem applies the default lg preset.
  • automatic inline margins center it when extra space is available.
  • 1rem inline padding, represented by paddingX="4", provides the default gutter.
TSX
<Container>  <PageContent /></Container>

The maximum width includes the inline padding. On a narrow viewport, the container fills the available width and the padding becomes the visible gutter. On a wide viewport, the maximum width limits the complete content region.

The five semantic sizes change the maximum width while retaining full available width and automatic centering. The default is lg.

sm

36rem · Focused reading

md

48rem · Forms and articles

lg

64rem · Standard application pages

xl

80rem · Dashboards and dense grids

full

100% · No maximum width

SizeMaximum widthGood starting point for
sm36remFocused reading and narrow flows
md48remForms, articles, and settings pages
lg64remStandard application pages
xl80remDashboards, data views, and wide grids
full100%Surfaces that should not be constrained

Choose a size from the content, not the viewport name. A settings form may remain sm on a large monitor, while a dense data table may need xl.

size is a semantic preset rather than a responsive prop. The container already responds naturally: it stays fluid below its ceiling and becomes fixed only when enough width is available.

paddingX accepts a spacing token or a mobile-first responsive object. Use smaller gutters where space is scarce and increase them only when the wider composition benefits from more breathing room.

TSX
<Container size="xl" paddingX={{ base: "4", md: "6", xl: "8" }}>  <Dashboard /></Container>

Omitted breakpoints inherit the last applicable value. In this example, 4 applies by default, 6 begins at md, and 8 begins at xl.

Set paddingX="0" when another boundary already owns the gutter. This is useful when Container sits inside a padded panel, but it should be intentional—removing the only viewport gutter can make content touch the screen edge.

The order determines which boundary spans the available width.

Place Container inside Section when backgrounds, borders, or dividers should extend beyond the constrained content:

TSX
<Section as="section" paddingY={{ base: "8", lg: "12" }} className="bg-elevation-surface-sunken">  <Container size="lg">    <Stack gap="6">...</Stack>  </Container></Section>

Place Section inside Container when the semantic region and its visual treatment should both remain constrained:

TSX
<Container size="lg">  <Section as="section" padding="6" className="rounded-xl border border-border-default">    ...  </Section></Container>

See the Composition Guide for the complete outside-in layout model.

Use width and maxWidth when a product surface needs a tokenized constraint outside the semantic presets.

A 48rem editorial measure

Use an explicit maximum when a product surface needs a content width that does not match one of the five semantic presets. The responsive inline padding remains independent.

size="full" · width="full" · maxWidth="3xl"

The three width props have different jobs:

  • size selects one of the five Container-specific maximum widths.
  • width sets the element’s preferred width from the shared size-token scale.
  • maxWidth replaces the preset ceiling with a value from the shared size-token scale.

width and maxWidth are direct token values, not responsive objects. Prefer a semantic size for standard page structure. Reach for explicit constraints when a real product requirement falls between presets or reuses a shared width token.

TSX
<Container size="full" width="full" maxWidth="3xl" paddingX={{ base: "4", md: "6" }}>  <Article /></Container>

Here size="full" removes the semantic ceiling, width="full" keeps the region fluid, and maxWidth="3xl" establishes a 48rem maximum.

Container does not set display, direction, gap, or alignment for its children. Put a layout primitive inside it:

TSX
<Container size="xl">  <Grid columns={{ base: 1, md: 2, xl: 3 }} gap="6">    {projects.map((project) => (      <ProjectCard key={project.id} project={project} />    ))}  </Grid></Container>

Avoid nested Containers by default. They can create duplicate gutters and competing maximum widths. If an inner reading column must be narrower than a wide page container, either give the inner content an intentional maxWidth or set the inner Container’s paddingX to 0 so only one boundary owns the gutter.

  • Do not use it as a card. Use Box or Card for a bordered or elevated surface.
  • Do not use it only to center one child on an axis. Use Center.
  • Do not use it to arrange siblings. Use Stack, Cluster, or Grid.
  • Do not wrap every component in its own Container. One page or section boundary should usually own the shared measure.

Sizes

smmdlgxlfull

API

PropTypeDefaultDescription
as ElementType div Rendered semantic element.
size ContainerSize lg Preset content max-width.
width / maxWidth SizeToken — Explicit structural constraints.
paddingX Responsive<Spacing> 4 Responsive inline padding.
native props React.HTMLAttributes<HTMLElement> — Forwards native attributes, events, aria-*, data-*, className, style, and ref.

Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props, including className, style, aria-*, and data-*.

Container is a div by default and adds no landmark or accessible name. Use as="main" only when it is the document’s single main region. Choose article, section, nav, or another semantic element only when the contained content has that meaning.

Do not introduce a semantic wrapper solely because Container is present. It can remain a div inside an already meaningful main or section. At narrow widths and high zoom, verify that inline gutters do not leave too little room for controls, tables, or long translated text.