Container
A layout primitive that constrains content to a maximum width, applies consistent horizontal padding, and centers it within the viewport. Seven sizes, seven padding presets, polymorphic rendering, and RTL support.
Playground
Installation
pnpm add @tessinaui/uiUsage
import { Container } from "@tessinaui/ui";<Container>
<h1>Dashboard</h1>
</Container>
<Container size="sm" padding="responsive" render={<article />}>
<p>A reading-width article with responsive gutters, rendered as <article>.</p>
</Container>
<Container size="full" padding="none">
{/* full-bleed section — e.g. a coloured hero background */}
</Container>Showcase
Sizes
Each size sets a max-width preset. Pick the narrowest size that still fits your content.
| Size | max-width | Pixels | Use case |
|---|---|---|---|
xs | max-w-md | 448px | Form dialogs, modal bodies, single column |
sm | max-w-2xl | 672px | Reading column, comfortable prose width |
md | max-w-4xl | 896px | Article or blog post |
lg | max-w-6xl | 1152px | Default — app content, settings pages |
xl | max-w-7xl | 1280px | Wide marketing page, dashboard |
2xl | max-w-[96rem] | 1536px | Ultra-wide dashboards, data tables |
full | max-w-none | 100% | No constraint — full-bleed sections |
Padding
Horizontal padding is applied inside the container. The responsive preset scales across breakpoints (tight on mobile, roomy on desktop) and is the default.
| Padding | Classes | Use case |
|---|---|---|
none | px-0 | When the parent already provides gutters |
xs | px-2 (8px) | Dense layouts |
sm | px-4 (16px) | Compact mobile |
md | px-6 (24px) | Standard desktop gutter |
lg | px-8 (32px) | Generous desktop gutter |
xl | px-12 (48px) | Marketing pages, hero sections |
responsive | px-4 md:px-6 lg:px-8 xl:px-12 | Default — scales with breakpoint |
Centering
Container centers horizontally with mx-auto by default. Turn it off for left-aligned layouts:
<Container center={false}>
{/* aligns to the start edge */}
</Container>Polymorphic rendering
Use the render prop to keep Container's styling but render as a different semantic element. This is the same pattern Tessina's Button and Link use.
<Container size="md" render={<main />}>
<h1>Page title</h1>
</Container>
<Container size="sm" render={<article />}>
{/* blog post */}
</Container>
<Container size="lg" render={<section aria-label="Features" />}>
{/* landing page section */}
</Container>Nested containers
A common pattern is a wide outer container for chrome (header, hero background) and a narrower inner container for reading content:
<Container size="xl" padding="responsive">
<Container size="sm" padding="none">
<article>{/* reading-width prose */}</article>
</Container>
</Container>Full-bleed backgrounds
To paint a full-width background while keeping content constrained, wrap a narrower Container inside a size="full" one (or use a plain <div> for the background):
<Container size="full" padding="none">
<div className="bg-foreground py-12">
<Container size="lg" padding="responsive">
<h1 className="text-background">Hero</h1>
</Container>
</div>
</Container>RTL
Container is direction-agnostic for layout (max-width, mx-auto, symmetric padding). Pass dir="rtl" to propagate direction to descendants:
<Container dir="rtl">
<article>محتوى</article>
</Container>Accessibility
- Container renders a plain
<div>by default — attach semantic meaning viarenderwhere appropriate (<main>,<section>,<article>,<nav>,<aside>). - Container has no keyboard or focus behaviour of its own.
- Avoid applying
max-wto interactive elements directly; let Container absorb the constraint so your buttons, inputs, and links keep their natural hit area.
API Reference
Container
| Prop | Type | Default | Description |
|---|---|---|---|
size | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "full" | "lg" | Maximum width preset |
padding | "none" | "xs" | "sm" | "md" | "lg" | "xl" | "responsive" | "responsive" | Horizontal padding |
center | boolean | true | Apply mx-auto to center horizontally |
render | ReactElement | — | Render as another element (e.g. <main />) — styling is merged, semantics change |
dir | "ltr" | "rtl" | — | Text direction, propagated to descendants |
className | string | — | Extra classes appended to the root element |
The component extends all standard HTML attributes for the rendered element.
HoverCard
A floating card that appears when a trigger is hovered or focused. Use for lightweight previews — user profiles, link previews, citations, or footnote definitions. Built on Base UI's preview-card primitive.
Stack
A flex-based layout primitive for arranging items in a row or column. Configurable direction, gap, alignment, justification, wrapping, reversal, dividers, inline display, polymorphic rendering, and LTR/RTL support. Ships with HStack and VStack convenience wrappers.