Skip to content

Horizontal bar chart ​

A card with a horizontal bar chart built on the Chart component: revenue by channel this quarter.

Installation ​

bash
npx bootcn add chart-bar-horizontal
bash
pnpm dlx bootcn add chart-bar-horizontal
bash
yarn dlx bootcn add chart-bar-horizontal
bash
bunx --bun bootcn add chart-bar-horizontal

The 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.

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 chart and card components.

Source ​

The exact files the CLI installs (chart-bar-horizontal@1.0.0). View on GitHub · Report an issue

html
<section class="card bootcn-card bootcn-chart-card" aria-labelledby="chart-bar-horizontal-title">
  <header class="bootcn-card__header">
    <h2 class="bootcn-card__title" id="chart-bar-horizontal-title">Horizontal bar chart</h2>
    <p class="bootcn-card__description">Revenue by channel this quarter.</p>
  </header>
  <div class="bootcn-card__content">
    <figure class="bootcn-chart" data-bootcn-chart>
      <figcaption class="visually-hidden">
        Revenue by sales channel, third quarter of 2026, in euros.
      </figcaption>
      <script type="application/json">
        {
          "type": "bar",
          "orientation": "horizontal",
          "categoryLabel": "Channel",
          "legend": false,
          "categories": ["Online shop", "Marketplace", "Retail", "Partners", "Wholesale"],
          "series": [
            {
              "name": "Revenue",
              "data": [48200, 31500, 22800, 14100, 9600]
            }
          ],
          "format": {
            "style": "currency",
            "currency": "EUR",
            "maximumFractionDigits": 0
          }
        }
      </script>
    </figure>
  </div>
  <footer class="bootcn-card__footer bootcn-chart-card__footer">
    <p class="bootcn-chart-card__trend">Online shop leads with 38%</p>
    <p class="bootcn-chart-card__note">July – September 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);
}

Released under the MIT License. Not affiliated with Bootstrap or shadcn/ui.