Layout
Container
A centred, max-width page container with a responsive inline gutter.
Purpose
Container constrains content to a readable maximum width, centres it with automatic inline margins
and adds an inline gutter (padding) that you can vary per breakpoint.
Import
import { Container } from "@neshel-ui/layout";Usage
Preview: container-sizes
Container size “sm”
Container size “md”
Container size “lg”
import { Container, Stack } from "@neshel-ui/layout";
import { Tile } from "./_tile";
const sizes = ["sm", "md", "lg"] as const;
/** Page container: a centred max-width with a responsive inline gutter. */
export default function ContainerSizes() {
return (
<Stack space="3">
{sizes.map((size) => (
<Container key={size} size={size} gutter={{ base: "2", md: "4" }}>
<Tile>Container size “{size}”</Tile>
</Container>
))}
</Stack>
);
}API
ContainerProps
| Prop | Type | Default | Description |
|---|---|---|---|
| as | LayoutElement | — | — |
| asChild | boolean | — | — |
| gutter | Responsive<SpaceValue> | — | — |
| ref | Ref<HTMLElement> | — | — |
| size | Responsive<ContainerSize> | — | — |
Also accepts the props of: React DOM attributes.
ContainerSize
type ContainerSize = "sm" | "md" | "lg" | "xl" | "2xl" | "full"size(responsive) setsmax-width;fullremoves the limit.gutter(responsive) uses the spacing tokens for the inline padding.
Common mistakes
- Importing the layout stylesheet before Tailwind: the preflight then removes the automatic margins. Import Tailwind first.
- Nesting Containers: one per page column is enough.