Bar chart
A card with a bar chart built on the Chart component: desktop and mobile visitors side by side.
- Version 1.0.0
- Bootstrap 5.3+
- Requires Bootstrap CSS
- Source on GitHub
html
<section class="card bootcn-card bootcn-chart-card" aria-labelledby="chart-bar-title">
<header class="bootcn-card__header">
<h2 class="bootcn-card__title" id="chart-bar-title">Bar chart</h2>
<p class="bootcn-card__description">Desktop and mobile visitors side by side.</p>
</header>
<div class="bootcn-card__content">
<figure class="bootcn-chart" data-bootcn-chart>
<figcaption class="visually-hidden">
Desktop and mobile visitors per month, January to June 2026.
</figcaption>
<script type="application/json">
{
"type": "bar",
"categoryLabel": "Month",
"categories": ["Jan", "Feb", "Mar", "Apr", "May", "Jun"],
"series": [
{
"name": "Desktop",
"data": [214, 312, 248, 96, 231, 276]
},
{
"name": "Mobile",
"data": [98, 186, 142, 171, 128, 165]
}
]
}
</script>
</figure>
</div>
<footer class="bootcn-card__footer bootcn-chart-card__footer">
<p class="bootcn-chart-card__trend">Up 5.2% this month</p>
<p class="bootcn-chart-card__note">January – June 2026</p>
</footer>
</section>Installation
bash
npx bootcn add chart-barbash
pnpm dlx bootcn add chart-barbash
yarn dlx bootcn add chart-barbash
bunx --bun bootcn add chart-barThe CLI also installs the design tokens and these blocks and components: chart, card. It prints the <link> and <script> tags to add to your layout.
- Load Bootstrap 5.3 (Bootstrap CSS) and the design tokens.
- Install the blocks and components it uses:
chart,card. - Copy the files from Source into your project. With the default
bootcn.jsonthey go here:
| File | Default location |
|---|---|
chart-bar.html | components/ui/chart-bar.html |
chart-bar.css | assets/css/chart-bar.css |
Usage
Replace the JSON configuration inside the <figure> with your data (see the Chart component for every option) and update the title, description and footer text. The card's CSS only styles the footer; the chart itself comes from the Chart component (chart.css and chart.js).
Accessibility
- The figure caption describes the data; it captions the "Show data" table, which holds every value for screen reader and keyboard users.
- The card is a section named by its heading.
Dependencies
- Bootstrap 5.3+ CSS.
themes/tokens/tokens.css.- The
chartandcardcomponents.
Source
The exact files the CLI installs (chart-bar@1.0.0). View on GitHub · Report an issue
html
<section class="card bootcn-card bootcn-chart-card" aria-labelledby="chart-bar-title">
<header class="bootcn-card__header">
<h2 class="bootcn-card__title" id="chart-bar-title">Bar chart</h2>
<p class="bootcn-card__description">Desktop and mobile visitors side by side.</p>
</header>
<div class="bootcn-card__content">
<figure class="bootcn-chart" data-bootcn-chart>
<figcaption class="visually-hidden">
Desktop and mobile visitors per month, January to June 2026.
</figcaption>
<script type="application/json">
{
"type": "bar",
"categoryLabel": "Month",
"categories": ["Jan", "Feb", "Mar", "Apr", "May", "Jun"],
"series": [
{
"name": "Desktop",
"data": [214, 312, 248, 96, 231, 276]
},
{
"name": "Mobile",
"data": [98, 186, 142, 171, 128, 165]
}
]
}
</script>
</figure>
</div>
<footer class="bootcn-card__footer bootcn-chart-card__footer">
<p class="bootcn-chart-card__trend">Up 5.2% this month</p>
<p class="bootcn-chart-card__note">January – June 2026</p>
</footer>
</section>css
.bootcn-chart-card__footer {
flex-direction: column;
align-items: flex-start;
gap: 0.25rem;
font-size: 0.875rem;
}
.bootcn-chart-card__trend {
margin: 0;
font-weight: 500;
}
.bootcn-chart-card__note {
margin: 0;
color: var(--bootcn-muted-foreground);
}
