Container

A padded and centred content column.

Welcome to arene

Build consistent interfaces with components you own.
import { Container } from "@/components/ui/container"
import { Heading } from "@/components/ui/heading"
import { Text } from "@/components/ui/text"
import { VStack } from "@/components/ui/stack"

export default function ContainerDemo() {
  return (
    <Container size="md">
      <VStack gap={2}>
        <Heading>Welcome to arene</Heading>
        <Text tone="muted">Build consistent interfaces with components you own.</Text>
      </VStack>
    </Container>
  )
}

Installation

pnpm dlx shadcn@latest add @arene/container

Needs the arene setup first.

Usage

import { Container } from "@/components/ui/container"
<Container size="md">Page content</Container>

size caps the full-width column in rem using the shared width scale: narrow (12rem), xs (20rem), sm (24rem), md (28rem), lg (32rem) and xl3 (48rem). Inline padding is space.s6. Override padding through xstyle. containerStyles exports base and widths.

Size

Choose a width from the shared scale. Padding stays inside the width cap.

narrow, 12rem
xs, 20rem
sm, 24rem
md, 28rem
lg, 32rem
xl3, 48rem
import * as stylex from "@stylexjs/stylex"
import { Container } from "@/components/ui/container"
import { VStack } from "@/components/ui/stack"
import { color, leading, radius, space, text } from "@/theme/tokens.stylex"

const styles = stylex.create({
  column: { backgroundColor: color.muted, borderRadius: radius.md, paddingBlock: space.s2 },
  content: {
    backgroundColor: color.background,
    borderRadius: radius.sm,
    paddingInline: space.s3,
    paddingBlock: space.s1_5,
    fontSize: text.sm,
    lineHeight: leading.sm,
  },
})

export default function ContainerSize() {
  return (
    <VStack gap={3} width="100%">
      <Container size="narrow" xstyle={styles.column}>
        <div {...stylex.props(styles.content)}>narrow, 12rem</div>
      </Container>
      <Container size="xs" xstyle={styles.column}>
        <div {...stylex.props(styles.content)}>xs, 20rem</div>
      </Container>
      <Container size="sm" xstyle={styles.column}>
        <div {...stylex.props(styles.content)}>sm, 24rem</div>
      </Container>
      <Container size="md" xstyle={styles.column}>
        <div {...stylex.props(styles.content)}>md, 28rem</div>
      </Container>
      <Container size="lg" xstyle={styles.column}>
        <div {...stylex.props(styles.content)}>lg, 32rem</div>
      </Container>
      <Container size="xl3" xstyle={styles.column}>
        <div {...stylex.props(styles.content)}>xl3, 48rem</div>
      </Container>
    </VStack>
  )
}

Composition

Pass render to choose a semantic element. Put its props on that element.

Your release summary
import { Container } from "@/components/ui/container"

export default function ContainerRender() {
  return (
    <Container render={<section aria-label="Release summary" />} size="md">
      Your release summary
    </Container>
  )
}

API reference

See Base UI's useRender reference for composition props. Native element props are forwarded.

PropTypeDefault
sizekeyof typeof widths"xl3"
renderuseRender.RenderPropNative element
xstyleStyleXStylesNone
classNamestringNone
styleCSSPropertiesNone

Data attributes

AttributeOnEffect
data-slot="container"rootIdentifies the component
data-sizerootMirrors size