Skip to content
Primitives

Container

Centered, padded content column with width presets — the component form of the .container utility.

Motionnone — layout primitive

Install

Install Kineto and follow the theme setup once in your app.

bash
npm install kineto
tsx
import { Container, containerVariants } from "kineto/container";

Preview

Centered content column

A consistent max width with responsive gutters. Switch the size prop to go from reading width up to full-bleed.

tsx
import * as React from "react";
import { Slot } from "@radix-ui/react-slot";
import { cva, type VariantProps } from "class-variance-authority";

import { cn } from "@/lib/cn";

const containerVariants = cva("mx-auto w-full px-4 sm:px-6 lg:px-8", {
  variants: {
    size: {
      sm: "max-w-3xl",
      default: "max-w-5xl",
      lg: "max-w-6xl",
      xl: "max-w-7xl",
      prose: "max-w-prose",
      full: "max-w-none",
    },
  },
  defaultVariants: {
    size: "default",
  },
});

export interface ContainerProps
  extends React.HTMLAttributes<HTMLDivElement>,
    VariantProps<typeof containerVariants> {
  /** Render as the child element (e.g. a `<section>` / `<main>`) instead of a `<div>`. */
  asChild?: boolean;
}

/**
 * Centered, padded content column — the component form of the `.container` utility. Use it to keep
 * page sections at a consistent max width with responsive gutters. Pick a `size` per context
 * (narrow `prose`/`sm` for reading, `xl`/`full` for dashboards and wide grids).
 */
const Container = React.forwardRef<HTMLDivElement, ContainerProps>(
  ({ className, size, asChild = false, ...props }, ref) => {
    const Comp = asChild ? Slot : "div";
    return (
      <Comp ref={ref} className={cn(containerVariants({ size }), className)} {...props} />
    );
  }
);
Container.displayName = "Container";

export { Container, containerVariants };

src/components/ui/container.tsx

Props

PropTypeDefaultDescription
size"sm" | "default" | "lg" | "xl" | "prose" | "full""default"Max-width preset (sm → reading width, full → no cap).
asChildbooleanfalseRender as the child element (e.g. a <section> or <main>) instead of a <div>.