Card
A content container with header, title, description, content and footer regions.
Installation
bash
npx bootcn add cardbash
pnpm dlx bootcn add cardbash
yarn dlx bootcn add cardbash
bunx --bun bootcn add cardThe CLI also installs the design tokens and these components: button. It prints the <link> and <script> tags to add to your layout.
Usage
html
<article class="card bootcn-card">
<header class="bootcn-card__header">
<h2 class="bootcn-card__title">Project settings</h2>
<p class="bootcn-card__description">Update your project name and visibility.</p>
</header>
<div class="bootcn-card__content">
<p class="mb-0">Changes are saved automatically.</p>
</div>
<footer class="bootcn-card__footer">
<button type="button" class="btn bootcn-button bootcn-button--outline bootcn-button--sm">
Cancel
</button>
<button type="button" class="btn bootcn-button bootcn-button--default bootcn-button--sm">
Save
</button>
</footer>
</article>Regions
bootcn-card__header— optional; contains the title and description.bootcn-card__title— the card heading.bootcn-card__description— supporting text under the title.bootcn-card__content— the main body.bootcn-card__footer— optional; usually holds actions.
Heading level
The example uses <h2>. Choose the heading level that matches the surrounding page structure; do not skip levels.
Dependencies
- Bootstrap 5.3+ CSS.
themes/tokens/tokens.css.- The Button component (
button) for the footer actions in the example. Any buttons can be used instead.
No JavaScript.
Accessibility
- Use a real heading element for
bootcn-card__title, not a styled<div>. - Keep the description associated with the title by grouping them in the header.
- Footer actions keep their own accessible names (see the Button component).
Source
The exact files the CLI installs (card@1.1.0). View on GitHub · Report an issue
html
<article class="card bootcn-card">
<header class="bootcn-card__header">
<h2 class="bootcn-card__title">Project settings</h2>
<p class="bootcn-card__description">Update your project name and visibility.</p>
</header>
<div class="bootcn-card__content">
<p class="mb-0">Changes are saved automatically for members of this workspace.</p>
</div>
<footer class="bootcn-card__footer">
<button type="button" class="btn bootcn-button bootcn-button--outline bootcn-button--sm">
Cancel
</button>
<button type="button" class="btn bootcn-button bootcn-button--default bootcn-button--sm">
Save
</button>
</footer>
</article>css
/* Tailwind-like card: rounded-xl, border, shadow-sm, p-6, no dividers. */
.bootcn-card {
overflow: hidden;
border: var(--bootcn-border-width) solid var(--bootcn-border-color);
border-radius: var(--bootcn-radius-xl);
background-color: var(--bootcn-background);
color: var(--bootcn-foreground);
box-shadow: var(--bootcn-shadow-sm);
}
.bootcn-card__header {
display: flex;
flex-direction: column;
gap: 0.375rem;
padding: var(--bootcn-card-padding);
}
.bootcn-card__title {
margin: 0;
font-size: 1rem;
font-weight: 600;
line-height: 1.25;
letter-spacing: -0.015em;
}
.bootcn-card__description {
margin: 0;
color: var(--bootcn-muted-foreground);
font-size: 0.875rem;
}
.bootcn-card__content {
padding: var(--bootcn-card-padding);
}
.bootcn-card__header + .bootcn-card__content {
padding-top: 0;
}
.bootcn-card__footer {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.5rem;
justify-content: flex-end;
padding: 0 var(--bootcn-card-padding) var(--bootcn-card-padding);
}
.bootcn-card__header + .bootcn-card__footer {
padding-top: 0;
}
