Vanilla Breeze

← All tutorials · ~15 minutes · Layer focus: custom elements & web components

Tutorial: Dashboard

Build an admin dashboard with four KPI tiles, a live chart, and a sortable table. The layout is semantic HTML, the cards are custom elements, and the chart and table are web components — each layer pulling its weight.

Step 1 — Semantic skeleton

A dashboard is just a page with a heading, four numbers, a chart, and a table. In semantic HTML that's exactly what we write — no framework vocabulary required.

Step 2 — Lay it out with data-*

Four KPIs in a responsive row? That's data-layout="grid" with a sensible data-layout-min. The header is a cluster. Nothing else changes.

One attribute per section, all on the elements we already had.

Step 3 — Upgrade KPI tiles to <layout-card>

A KPI tile is a surface with a border, padding, and a consistent inner rhythm. That's what <layout-card> is for. You get the visual treatment, keep the semantic <article> meaning, and gain no JavaScript.

<layout-card> variants: outlined, elevated, ghost. Padding scale: s, m, l. The whole component is CSS — no runtime cost.

Step 4 — Reach for web components only where you need JS

Two places on this page genuinely benefit from JavaScript: the chart (rendering to canvas) and the data table (sorting, filtering). For everything else we stayed declarative.

The chart

<chart-wc> is a thin Chart.js wrapper driven entirely by data attributes. Pass a JSON data-values payload and you get an accessible, themed, responsive chart that respects the current theme tokens.

To use <chart-wc>, add one CSS and one JS file to your page:

Supported types: line, area, bar, column, pie, scatter, bubble.

The sortable table

A plain <table> already has semantics and a readable default style. Wrap it in <data-table> and every column header becomes clickable, sortable, and announces its state to screen readers — without you writing any JavaScript.

If JavaScript fails to load, the plain <table> is still perfectly readable. That's the whole point.

What you learned