Skip to content
Slotted

Container

Bounds the width of a page or a section, insets it from the edge and places it when space is left over.

Usage this month

Seats are billed per active user and settled with the invoice on the first business day of the next month. Archived warehouses stop counting from the day they are archived.
42 active seats$1,260.00 on December 1
Open

Installation

The packages are a 0.x beta on npm, and their public API changes between beta releases without deprecation. One line installs the binding and the default theme.

bash
pnpm add @slotted/react @slotted/theme @slotted/themes

Container, Stack, Inline and Grid

Use Container once per page or section to decide how wide its content may grow. Use Stack to lay children out in one column, Inline to lay them out in one row, and Grid to arrange cells in equal columns; none of the three bounds its own width. A container paints nothing and adds no semantics. Its root is a div; pass render in React, or write slContainer on a main, section or article in Angular, to change the element. Wrap text in an element: a run of text written directly inside the container cannot be placed in the column.

Size

size names what the column is bounded to. measure is a reading line of 65ch, the width of 65 zeros in the type the text is set in. content is 56rem, the default. wide is 80rem. full takes the space the frame gives up to 120rem. bleed has no maximum. full and bleed keep the inset. Each maximum is a theme token. The preview is narrower than a page, so this example lowers four of them, and every size stops at a width of its own.

measure
content
wide
full
bleed

Inset

inset is the minimum gap between the column and the edge of the space the container was given, a step on the space scale from 0 to 12, 6 by default. It applies to both sides and holds when the container is narrower than its maximum. Each container below sits inside a card, so the gap to the card’s edge is the inset.

inset: 0
inset: 3
inset: 6
inset: 12

Alignment

align sets where the column sits when space is left over: center by default, start or end. The values are logical, so a right-to-left document mirrors them. In each card below the column is bounded to a measure of 40ch, which leaves room to move.

align: center
align: start
align: end

Breakout

ContainerBreakout is a direct child that leaves the bound and reaches both edges of the container, such as a table, a banner or a strip of media inside a page of prose. It answers the container, not the window, and ignores the inset. The next child in the container returns to the bounded column. A container separates nothing, so this one states a row gap from the space scale. To put bounded content back inside a breakout, nest another Container in it.

Quarter-end stock count

Counts finished at 14 of 14 sites. Three sites report a variance above 2% and are listed below.
Singapore +2.4%, Chicago -3.1%, Osaka +2.2%. 41,926 units counted.
The text returns to the same column after the breakout.

Application defaults

An application states its page bounds once with ContainerDefaultsProvider in React or provideContainerDefaults in Angular. Every container under it takes size, inset and align from the provider, and a container that states a value of its own keeps it.

Takes size, inset and align from the provider.
States its own size, inset and align.

Accessibility

  • Container has no role and no ARIA. It bounds what you write inside it, and the children keep whatever semantics they already had. Render a main, a section or an article through render so the document says what it means.
  • size="measure" bounds the line at 65ch. WCAG 2.2 SC 1.4.8 asks for no more than 80 characters per line, and technique C20 asks that the width be set in a relative measurement; ch is relative to the inherited type, so the bound follows a reader who enlarges the text rather than fighting them.
  • Every other step is stated in rem, so the whole page grows with the browser zoom WCAG SC 1.4.4 requires.
  • The column collapses continuously through min(), and every child is allowed to shrink below its content, so a long unbroken token overflows its own box rather than widening the page — the two-axis scroll SC 1.4.10 refuses.
  • Nothing reorders children. Visual order stays DOM order, which is what SC 1.3.2 asks for, and a breakout is read where it is written.
  • The root is a grid, so a run of text written directly inside it becomes an item nothing can place in the column. Wrap text in an element.

API

container

Props

size'measure' | 'content' | 'wide' | 'full' | 'bleed'Default content
Names what the column is bounded to. measure is a reading line of 65ch, content is 56rem and wide is 80rem. full takes the space the frame gives, up to 120rem (--slotted-container-full). bleed removes the maximum. full and bleed keep the inset.
inset0 | 1 | … | 12Default 6
Sets the minimum gap between the column and the edge of the space the container was given, as a step on the space scale.
align'center' | 'start' | 'end'Default center
Sets where the column sits when space is left over. The value is logical, so a right-to-left document mirrors.
render(props) => ReactNode
On Container, ContainerBreakoutRenders a different root element from the props it receives.

Theming

Each token is a CSS custom property: set it in a theme, or on any element to retune every container inside it.

Container tokens

TokenDefault
--slotted-container-content56rem
--slotted-container-full120rem
--slotted-container-measure65ch
--slotted-container-wide80rem

Theme tokens it reads

TokenDefault
--slotted-space-10.125rem
--slotted-space-102.5rem
--slotted-space-113rem
--slotted-space-124rem
--slotted-space-20.25rem
--slotted-space-30.375rem
--slotted-space-40.5rem
--slotted-space-50.75rem
--slotted-space-61rem
--slotted-space-71.25rem
--slotted-space-81.5rem
--slotted-space-92rem