Utilities✨ Premium

Dashboard Widget

Figures widget that reads the width of its own slot: stacked when narrow, two columns next, then one row with a mini bar chart from 300 px.

CSS@containerDashboard

Updated

This effect is part of Effect.Labs — 840 vanilla effects, some free, some premium. Utilities has 43 effects, including 3 free. Explore the category →

3 usage examples

Halvorine Museum — the same traffic widget in the content and in the “Summary” column — Dashboard Widget example 1

① Halvorine Museum — the same traffic widget in the content and in the “Summary” column

WhenOn the back office “Website” page, the main block shows visits, tickets, conversion and duration on one row with the week's bar chart; the right column reuses exactly the same code, which stacks itself.
WhyOne component to maintain for two slots: the narrow column needs no “mobile” variant and no extra class.
SettingsTwo identical roots: one in a column of about 330 px (4 columns + chart), the other in a 168 px column (1 column). Only the texts and figures are the museum's.
Quintaroc — occupancy tile stretched in a customisable dashboard — Dashboard Widget example 2

② Quintaroc — occupancy tile stretched in a customisable dashboard

WhenIn “Editing layout” mode you pull the green handle of the “Today” tile: from 250 to 300 px the four figures sit on two rows, beyond that they move onto one row and the seven-day chart appears; the agenda next to it narrows.
WhyThe tile stays readable at every size the user picks, without the dashboard having to know its thresholds.
SettingsThe tile width is set by the scene's handle (pointer or arrow keys); for the capture, the scene stretches it in a loop between 250, 310 and 400 px. The widget code is not modified.
Velmorade — listing summary that folds when the inbox opens — Dashboard Widget example 3

③ Velmorade — listing summary that folds when the inbox opens

WhenThe seller checks the figures for their sideboard (views, saves, contacts, duration); clicking “Messages” opens the conversation on the right and the summary goes back to two columns without the chart.
WhyThe opening panel breaks nothing: the widget measures its new slot and keeps all four figures visible.
SettingsThe scene's “Messages” button toggles a class that gives the panel 262 px (a width transition in the scene); without a click, the scene opens and closes it in a loop for the capture. Light page around, original dark widget.

How it works

The .fx-0748-root root declares itself a container (container: dwg / inline-size) and takes the full width of its parent. The @container dwg rules compare that width with two thresholds; the browser window never comes into it. The same widget can therefore show wide in the main content and narrow in a side column of the same page.

Below 240 px, the four figures in .dwg-stats stack in one column. From 240 to 299 px they form a two-by-two grid. From 300 px they line up in four columns and the .dwg-chart row (seven bars whose height is written as style="height:…%") appears under the figures.

No JavaScript: everything lives in the CSS. The layout change is instant (a column count is not interpolated) and nothing moves continuously, so the widget is unaffected by the “reduce motion” setting.

Accessibility

  • Real text: title in an <h4>, each figure and its label are text read in order (value then label). Adjust the heading level to your page.
  • Decorative chart: .dwg-chart carries aria-hidden="true" because its bars have neither values nor legend. If they carry information, add a text summary next to the widget.
  • Contrast: labels in 55 % white on #0a0a0f, figures in pure white; the green #10b981 badge on its tinted background stays readable at small size.
  • Keyboard and touch: nothing to activate, the widget has no interactive element. The column change comes from width, so it behaves the same with a finger or a mouse.
  • Motion: no transition or animation in the code, nothing to switch off under prefers-reduced-motion.

Browser compatibility

CSS-only container queries (Chrome 105, Firefox 110, Safari 16 according to @mdn/browser-compat-data 8.1.8). Measured in Chromium 151, Firefox 153 and WebKit 26.5: 1 column at 200 px, 2 columns at 250 px, 4 columns plus chart at 300 and 600 px; no overflow on a 390 px page; two copies side by side each keep their own layout.

Chrome 105+✓ Full (measured)
Firefox 110+✓ Full (measured)
Safari 16+✓ Full (measured in WebKit)
Edge 105+✓ Full
Mobile iOS 16+✓ Full
Android Chrome 105+✓ Full

A browser without @container keeps the base layout: stacked figures, chart hidden. The content stays complete and readable.

The code

HTML structure to paste into your page (the CSS + JS come with your purchase):

index.html — structure
<div class="fx-0748-root">
  <div class="dwg-card">
    <div class="dwg-head"><h4>…</h4><span class="dwg-badge">…</span></div>
    <div class="dwg-stats">
      <div class="dwg-stat"><span class="dwg-stat-val">…</span><span class="dwg-stat-label">…</span></div>
      <!-- 4 figures -->
    </div>
    <div class="dwg-chart" aria-hidden="true"><span class="dwg-bar" style="height:40%"></span><!-- 7 bars --></div>
  </div>
</div>

One-time payment, no subscription — the code is yours forever

Customize

Options passed to the API or data-* attributes:

Option / propertyDefaultEffect
Thresholds (CSS — @container dwg (min-width: 240px) and (min-width: 300px)) 240 px → 2 columns, 300 px → 4 columns + chart Move both values to suit your labels: a long label needs a higher four-column threshold (360 px for instance).
Container name (CSS — container: dwg / inline-size) dwg Rename it in the declaration and in both @container rules if your page already uses that name.
Figures and labels (HTML — .dwg-stat-val, .dwg-stat-label) 4 neutral sample figures Replace them with your values; with three or five figures, also change repeat(4, 1fr) in the 300 px tier.
Chart bars (HTML — style="height:…%" on .dwg-bar) 7 bars from 40 to 90 % Each percentage is a bar's height in a 40 px row; add or remove <span> elements, they share the width.
Colours (CSS — .dwg-bar, .dwg-badge, background of .fx-0748-root) #8b5cf6 → #a78bfa gradient, #10b981 badge, #0a0a0f background Change the bar gradient and the badge colour; for a light background, also invert the figure colour.
Title (HTML — <h4> in .dwg-head) “Analytics” Change the text and, if needed, the heading level; the style follows as long as the tag stays inside .dwg-head.

FAQ

It only looks at its parent's width. If the parent keeps the same width (fixed column, 320 px card), the widget does not move: that is intended. Test by changing the width of the box that holds it.
The widget treats them as decoration without a legend. For a readable chart with months and values, a dedicated chart component is a better fit; here, remove aria-hidden only if you add text saying what the bars show.
Yes, with no change: each root is its own container, so each copy picks its layout from the room it has. There is no id and no shared script.