Skip to Content
Neshel-UI
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.tsx
import { Container } from "@neshel-ui/layout";

Usage

Preview: container-sizes
Preview theme
Container size “sm”
Container size “md”
Container size “lg”
container-sizes.tsx
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

ContainerProps
PropTypeDefaultDescription
asLayoutElement——
asChildboolean——
gutterResponsive<SpaceValue>——
refRef<HTMLElement>——
sizeResponsive<ContainerSize>——

Also accepts the props of: React DOM attributes.

ContainerSize

type ContainerSize = "sm" | "md" | "lg" | "xl" | "2xl" | "full"
  • size (responsive) sets max-width; full removes 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.
Edit on GitHub

On this page