Live Docs

Layout /

stable

Box

Primitive wrapper paling dasar untuk styling/layout ringan dengan dukungan polymorphic `as`.

import { Box } from "@naraya/ui";

Overview

Box adalah building block minimal. Pakai saat butuh wrapper semantic tambahan tanpa behavior layout khusus.

Examples

Default

Basic box
<Box>Basic box</Box>

Polymorphic as

Header region
Main content
<Box as="header">Header region</Box>
<Box as="main">Main content</Box>

Utility wrapper

Info
Success
<Box style={{ padding: "0.5rem 0.75rem" }}>
  <Badge tone="info">Info</Badge>
</Box>

Props

PropTypeDefaultDescription
asElementType"div"Render sebagai tag/komponen lain.
childrenReactNodeIsi konten Box.
...restHTMLAttributes<HTMLElement>Props native element (className, style, id, dsb).

Tokens Used

--border-subtle

Contoh border box wrapper

--bg-surface

Contoh background box container

Accessibility

  • Pilih nilai prop as sesuai semantic struktur halaman (section, article, nav, dsb).
  • Jangan gunakan Box kosong untuk layout jika komponen layout spesifik lebih tepat (Stack/Grid).