Container

A centered, max-width content column with consistent horizontal gutters.

import { ... } from '@corndev/ui'
sm — 640px max-width
md — 960px max-width (default)
lg — 1280px max-width
fluid — full width with gutters

HTML

No JavaScript required — these classes are the whole component.

<div class="corn-container" data-size="md">Page content</div>

Classes

Class
.corn-container

Attributes

AttributeValues
data-sizesm|md|lg|fluid

Vanilla JS

Optional. createContainer only adds and removes the classes and attributes above, so the HTML is equivalent. Reach for it when you need to change options at runtime.

import { createContainer } from '@corndev/ui';
import '@corndev/ui/theme';

const el = document.querySelector('#target');
const instance = createContainer(el, { /* options */ });

Options

OptionTypeDefault
size'sm'|'md'|'lg'|'fluid''md'

React

Container — from @corndev/ui-react.

Props

PropTypeDefault
size'sm'|'md'|'lg'|'fluid''md'
asReact.ElementType'div'
childrenReact.ReactNodeundefined
classNamestringundefined

Sizes

Container has four width presets. The coloured background shows the container boundary.

sm — 640px max-width

md — 960px max-width (default)

lg — 1280px max-width

fluid — full width with gutters

<Container size="sm">...</Container>
<Container size="md">...</Container>
<Container size="lg">...</Container>
<Container size="fluid">...</Container>

Typical page layout

<Container size="md">
  <Stack gap="lg">
    <h1>Page title</h1>
    <p>Page content goes here.</p>
  </Stack>
</Container>

Polymorphic as prop

<Container as="main" size="md">
  ...
</Container>