Skip to main content

Container

Centers content and caps its width. Stock Mantine Container carrying the design system's four width steps in place of Mantine's own six, plus a responsive side gutter at the two largest steps that Mantine doesn't provide on its own.

Base
Mantine + override
Import
{ Container } from '@mantine/core'
Source
src/themes/theme.ts
src/themes/style-overrides/container.module.css

Usage​

Innhold

size
xs
sm
md
lg
fluid
React
<Container size="md">
{/* ... */}
</Container>

This preview frame is narrower than every step but xs (354px), so sm, md and lg all render at the frame's full width here — drag the slider to xs to see the actual difference; the table below is the source of truth for what each step changes. xl is left out of the control on purpose; see the note in Props. fluid ignores size entirely and stretches the container to 100% of its parent's width, exactly as it does in stock Mantine.

Sizemax-widthSide gutter
xs354pxConstant spacing.md padding — Mantine's stock behaviour; no override exists for this step.
sm768pxSame as xs.
md1440pxNo padding above the breakpoint; spacing.md padding reappears only below it.
lg1920pxSame pattern as md.

The md/lg breakpoints in container.module.css are written in px, not rem(): rem() compiles to a calc() expression carrying --mantine-scale, and a CSS custom property cannot appear inside an @media condition — it would silently disable the rule. xs and sm have no dedicated rule in that file, so they keep Mantine's always-on padding-inline rather than gaining the breakpoint-gated gutter.

Props​

Only what this design system changes. Everything else is Mantine's — read the full props table there.

PropertyTypeAllowed valuesDefaultDescription
sizeMantineSize | numberxs · sm · md · lg · numbermdCaps the content width — 354, 768, 1440 or 1920px. A number still converts to rem, as in stock Mantine. Mantine's own xl step is not one of the four redefined here: passing size="xl" falls through to the generic numeric branch, which only converts numbers, so the keyword comes out unchanged and produces an invalid max-width. Stick to the four steps or a number.

Accessibility​

Container renders a plain <div> with no landmark role of its own. If it wraps a page's main content, pass component="main" (Container forwards an unrecognized component prop straight to the underlying Box) rather than relying on the container to announce anything by default.