Skip to content
Cynosurev0.5.0
SearchStorybookGitHubnpmColour mode: System. Switch to Light

Components / Structure

Container

The page column. It centres its content, caps how wide it gets and adds side gutters, so every page of an app lines up. It is layout only: no background, border or text styles.

Centred column with gutters

When to useLink to "When to use"

  • The content of a page or screen: wrap it once, usually inside AppShell's main area, so headings and content share the same edges on every page.
  • A reading column: size="sm" or size="md" keeps lines of text short on wide screens.

Use something else when:

  • you only need padding around a group of items: padding on Stack, Inline or Grid
  • you want a visible box with a surface and border: Card
  • you are laying out items in columns: Grid, inside the Container

UsageLink to "Usage"

tsx
Copy
import { Container, Stack } from "@arshad-shah/cynosure";

<Container as="main" paddingBlock="8">
  <Stack gap="6">
    <PageHeader title="Tasks" />
    <TaskList />
  </Stack>
</Container>
<Container size="sm">…</Container>
<Container size="full" padding="8">…</Container>

SizesLink to "Sizes"

size sets the widest the column gets, gutters included: sm 640px, md 768px, lg 1024px (the default) and xl 1280px. full has no cap and keeps the gutters. Below its cap the column is exactly as wide as its parent, so it never overflows a narrow one.

Each size is capped at its token

GuttersLink to "Gutters"

padding is the space token for the two side gutters (the default is space 6, 16px). paddingBlock adds padding above and below. padding="0" removes the gutters.

Gutters use space tokens

Not centredLink to "Not centred"

center={false} keeps the column at the inline start: the left edge, or the right edge in right-to-left text.

Not centred

PropsLink to "Props"

Every prop of Container
PropWhat it doesTypeDefault
size
Widest the column gets, gutters included; full has no limit. Default "lg"."sm" | "md" | "lg" | "full" | "xl""lg"
padding
Space token for the gutters at the inline start and end. They never get narrower than the device's safe area (a phone's notch or rounded corners). Default: the --cy-container-padding token (space 6).Space
paddingBlock
Space token of padding at the block start and end (top and bottom). Default: none.Spacenone
center
Centre the column in the space around it. false keeps it at the inline start. Default true.booleantrue
as
Element to render: main for the page's main content, once per page. Default "div"."div" | "section" | "article" | "main""div"
className
Added to the root element, for layout.string
style
Layout only. Change the widths through the --cy-container-* tokens.CSSProperties
children
The page content.ReactNode
data-testid
Set on the root element, for tests.string
hideBelow
Hidden while the window is narrower than this breakpoint (md: below 45rem)."sm" | "md" | "lg" | "xl"
hideAbove
Hidden from this breakpoint upwards (md: 45rem and wider)."sm" | "md" | "lg" | "xl"

Generated from the type definitions in @arshad-shah/cynosure 0.5.0.

Behaviour and accessibilityLink to "Behaviour and accessibility"

Behaviour and accessibility, table 1
SettingElement and what assistive technology gets
as="div" (default)A div: no role
as="main"The page's main landmark. Use it once per page
as="section"A section: a region landmark only when you give it a name (aria-label or aria-labelledby)
as="article"An article
  • Width: fills its parent up to the cap, also inside a flex row or a Stack that centres its children.
  • Safe area: each gutter is at least the device's safe-area inset on that side, so content clears a phone's notch or rounded corners in landscape. Browsers only report insets when the page's viewport meta tag has viewport-fit=cover.
  • Right to left: the gutters are equal on both sides and the column stays centred.
  • Nesting: a nested Container has its own default gutters and inherits no padding from its parent.
  • Text: font, size and colour are inherited from the page.
  • Keyboard: none. A Container is never focusable.

TouchLink to "Touch"

Nothing in a Container can be pressed, so it has no hit area. On phones the gutters keep content off the screen edges and the safe-area insets.

ThemingLink to "Theming"

Theming, table 2
TokenDefaultWhat it sets
--cy-container-size-sm640pxWidest a size="sm" container gets
--cy-container-size-md768pxWidest a size="md" container gets
--cy-container-size-lg1024pxWidest a size="lg" container gets
--cy-container-size-xl1280pxWidest a size="xl" container gets
--cy-container-padding--cy-space-6Side gutters when padding is not set
ts
Copy
createTheme({ components: { container: { sizeLg: "1100px", padding: "24px" } } });

className and style are for layout only (margin, placement, a minimum height).

AppShell · Stack · Grid · Card

These examples run Cynosure 0.5.0 (commit 50ce30b), the version on npm.

Getting started
Theming
Icons
Accessibility
Code editors and highlighters
Using Cynosure without React
Build-tool adapters
Components
Accordion
AppShell
AspectRatio
Breadcrumbs
Calendar
Card
Container
Disclosure
Divider
DocumentViewport
Grid
Inline
PageHeader
PanZoomCanvas
ScrollArea
SideNav
SortableList
SplitPane
Stack
StatusBar
Tabs
TitleBar
Toolbar
Tree
VirtualList
ZoomControls
Announcer
Avatar
Badge
CodeBlock
DescriptionList
EmptyState
ErrorBoundary
Field
Heading
IconTile
Image
Kbd
List
LoadingDots
Notice
ProgressBar
Prose
Skeleton
Stat
Steps
Table
Text
Button
Checkbox
Checklist
ColorField
ColorSwatches
Combobox
CompareSlider
CopyButton
DateField
FileDrop
IconButton
KeyValueEditor
Link
NumberField
Pagination
PathField
RadioGroup
SearchField
SegmentedControl
Select
SelectionFrame
SignaturePad
Slider
Switch
TagInput
TextArea
TextField
ThemeToggle
TimeField
ButtonBase
ChoiceBase
DialogBase
FileInputBase
HiddenValue
Icon
InputBase
LinkBase
LiveRegion
TextAreaBase
ChatMessage
Choice
DataGrid
DeviceFrame
HighlightedText
HotkeyField
ListRow
OptionList
OverlayFrame
QRCode
RowActions
Section
SiteFooter
SiteHeader
SkipLink
SortButton
VisuallyHidden
CommandPalette
ContextMenu
Dialog
FloatingToolbar
HoverCard
Menu
Menubar
Popover
ProgressOverlay
Sheet
Toast
Tooltip
Changelog