Article Title
This Box is rendered as an article element.
A generic unstyled layout component that acts as a flexible foundation for building custom structures and semantics.
npm install @adaptavant/eds-coreimport { Box } from '@adaptavant/eds-core';By default, Box renders as a div element. Use Tailwind CSS classes to style it.
<Box
className="
bg-accent
text-onPrimary
p-4
rounded-lg
flex
items-center
justify-center
h-32
"
>
This is a Box component
</Box>
Box is polymorphic and can render as any HTML element using the as prop. This is useful for maintaining semantic HTML while applying custom styles.
This Box is rendered as a section element.
This Box is rendered as an article element.
<Stack className="gap-4">
{/* Render as a section */}
<Box
as="section"
className="
bg-neutral-subtle
p-4
rounded-lg
"
>
<Box as="h2" className="text-heading-20 mb-2">
Section Heading
</Box>
<Box as="p" className="text-body-14">
This Box is rendered as a section element.
</Box>
</Box>
{/* Render as an article */}
<Box
as="article"
className="
border
border-secondary
p-4
rounded-lg
"
>
<Box as="h3" className="text-heading-16 mb-2">
Article Title
</Box>
<Box as="p" className="text-body-14">
This Box is rendered as an article element.
</Box>
</Box>
{/* Render as a button */}
<Box
as="button"
className="
bg-accent
text-onPrimary
px-4
py-2
rounded-md
hover:bg-accent-hover
transition-colors
"
onClick={() => alert('Clicked!')}
>
I'm a button!
</Box>
</Stack>
| Prop | Default | Description |
|---|---|---|
as? | 'div' | React.ElementTypeThe element type to render. Can be any valid HTML element (e.g., 'div', 'section', 'article', 'button') or a React component. |
children? | _ | React.ReactNodeThe content to be rendered inside the Box. |
className? | '' | stringCSS class names to apply to the Box. Supports Tailwind CSS utility classes. |
style? | {} | React.CSSPropertiesInline styles to apply to the Box. |