Bootstrap 5 chart cards combine Bootstrap's card component with Chart.js 4 for dashboard data visualization. This page covers 4 chart card patterns — line, bar, doughnut and sparkline.
Setup
<!-- Add Chart.js before closing body -->
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script>
Basic Pattern
<div class="card border-0 shadow-sm">
<div class="card-body">
<canvas id="myChart" height="160"></canvas>
</div>
</div>
<script>
new Chart(document.getElementById('myChart'), {
type: 'line',
data: { labels: [...], datasets: [{ data: [...] }] },
options: { responsive: true }
});
</script>
Frequently Asked Questions How do I add Chart.js to Bootstrap 5?▲ Add the Chart.js CDN before your closing body tag: <script src='https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js'></script>. Create a canvas element inside your Bootstrap card. Initialize with: new Chart(canvas, { type, data, options }).
How do I make Chart.js responsive inside a Bootstrap card?▼ Chart.js is responsive by default when responsive:true is set in options. Put the canvas inside a Bootstrap card-body. Set height on the canvas attribute for aspect ratio control: <canvas height='160'>. Don't set a fixed CSS height on the canvas itself.
How do I change Chart.js colors to match Bootstrap 5 brand colors?▼ Pass your colors directly in the dataset: borderColor:'#fd4766', backgroundColor:'rgba(253,71,102,0.08)'. For multiple datasets use an array of colors. Bootstrap's CSS variables are not accessible inside Chart.js — use hex/rgba values directly.
How do I create a sparkline chart in Bootstrap 5?▼ Use Chart.js line chart with all display elements hidden: pointRadius:0, scales.x.display:false, scales.y.display:false, plugins.legend.display:false, plugins.tooltip.enabled:false. Set a small canvas height (40-60px) and fill:true for the area effect.
Need a Full Bootstrap 5 Admin Dashboard? Get a complete Angular 21 + Bootstrap 5 dashboard with 50+ components — built by the same team behind BootstrapPlanet.
Browse Templates → Use code FIRST30 for 30% off your first purchase.
Related Components