Theme studio

Design a theme, preview it live, then export it. Saved in this browser.

Quick picks #10b981
Generated scale
50100200300400500600700800900
Some text is below AA

HistogramChart

  • Stable
  • WCAG 2.2 evidence
  • RTL

A histogram: how often values fall in each range. Give raw values and the chart bins them (bins, binWidth or thresholds), or give bins that are already counted. Title, range switch, KPI and text alternative are the shared card; the plot is laid out for the width of its container and renders on the server from the same props. Accessibility: the figure is named by title and described by summary; the data table has every bin with its range, both edges, its count and its share, so the binning is stated and not only drawn (WCAG 1.1.1, 1.3.1). The plot is ONE tab stop: Left and Right move between bins, Home and End jump to the ends, Page Up and Page Down skip a tenth; a bin is announced with its range and count. Hover or focus shows a tooltip that stays while hovered and closes with Escape (1.4.13, 2.1.1). Bin labels are ranges in the locale's digits and thin out or rotate on a narrow container (1.4.10); the plot stays left-to-right in right-to-left pages. The draw-in is behind motion-safe:. The bars are one series, so colour does not carry a distinction (1.4.1); the median and other markers carry their own text. Counting: a bin includes its start and excludes its end; the last bin of raw data includes its end. Bars are equal in width whatever the bin width in data units, so uneven thresholds show counts per bin, not densities. valueFormat, formatValue and formatAxisValue format the measured values (edges, markers), counts always use the locale's number format. The bin labels on the axis use the full format of an edge (a compact "0.1" for both 0.05 and 0.1 would be wrong) unless you give formatAxisValue. Consumer duties: a title that asks the question, a summary with the main message, the unit of the x axis, saying what a marker is.

import { HistogramChart } from "@nexera-ui/react";
Loading example…
12
examples
24
props
2
live controls
1
platform
8
WCAG criteria
1
block uses it

Try every prop. Copy the code.

Change the props and the code updates. Check light and dark, LTR and RTL, and phone width.

Loading…
title
description
Generated code
import { HistogramChart } from "@nexera-ui/react";

<HistogramChart />

Examples 11

The same examples as Storybook, rendered live. Open Code to copy one.

Bin width

Raw values, one-year bins (binWidth): the chart counts them and labels the bins as ranges ("0–1", "1–2").

Loading example…

Thresholds

thresholds are the edges between bins: the first bin is open below the first edge ("<1") and the last open above the last ("8+").

Loading example…

Bin count

bins as a number asks for about that many bins; the edges are rounded to nice numbers.

Loading example…

Formatted values

Percent values with valueFormat: the edges are formatted as percentages in the locale, the counts as plain numbers.

Loading example…

Loading

Loading example…

Empty

Loading example…

Error state

Loading example…

Single point

One value is one bin with one bar.

Loading example…

Many points

5000 values in about 120 bins: range labels thin out to what fits and the keys still reach every bin (Page Down skips 12).

Loading example…

Long labels

Long title, description, axis title and range labels: the header wraps, the labels rotate or thin out, nothing is cut off.

Loading example…

Right to left

Right-to-left page: the card, header and table mirror, the plot keeps its left-to-right axis, digits and labels follow the locale.

Loading example…

Props 24

Press "Try it" on a card to load that prop into the playground.

24 props shown

valuesNexera
readonly number[]

The raw measurements to count into bins (tenure in years of every employee). Values that are not finite numbers are ignored. Give values, or already counted bins, not both: counted bins win.

Default –
binsNexera
number | readonly HistogramBinData[]

How to bin. A number is about how many bins to make from values (the edges are rounded to nice numbers, so the count can differ a little); an array is data that is already counted, one entry per bin ({ start, end, count, label? }, null for an open end). Without it and without binWidth and thresholds, the bin count follows Sturges' rule (log2 of the number of values plus one, at most 30).

Default –
binWidthNexera
number

Width of every bin in the unit of values (1 for one-year bins). The edges are multiples of it. Wins over a bins number.

Default –
thresholdsNexera
readonly number[]

The edges between bins. [1, 2, 3, 4, 5, 6, 7, 8] makes the open-ended bins "<1" and "8+" and seven bins between. Wins over binWidth and bins.

Default –
valueLabelNexera
string

Name of what is counted (Employees): the legend-free series name in the tooltip, the point labels and the table column. Translate it.

Default Count
xAxisLabelNexera
string

Title of the x axis, under the bin labels. Label the unit.

Default –
markersNexera
readonly HistogramMarkerInput[]

Vertical markers with a label. The line is decorative: the label is also in the plot's name.

Default []
styleIndexNexera
number

Index of the series style (colour chart-1..8). Figma colours the bars chart-2.

Default 1
labelsNexera
Partial<HistogramLabels>

Texts of the table and the tooltip that the chart invents. Translate them.

Default –
title*Nexera
string

Chart title: the question the chart answers ("Headcount"). Required: it names the figure, the plot and the data table (WCAG 1.1.1).

Default –
descriptionNexera
ReactNode

Secondary line under the title.

Default –
summary*Nexera
string

One or two sentences with what the chart shows and its main message ("Headcount grew from 96 to 128 over twelve months"). Required: it describes the figure for assistive technology (WCAG 1.1.1); the data table has the details.

Default –
rangeNexera
ChartRangeProps

Range switch in the header: 3M, 6M, 12M. Pass the data of the chosen range back in.

Default –
actionsNexera
ReactNode

Extra controls in the header, after the range switch.

Default –
kpiNexera
ChartKpiProps

KPI row above the plot: the headline number with an optional label or change badge.

Default –
stateNexera
ChartPlotState

The state that replaces the plot: loading (skeleton), empty or error. A chart without a value to plot shows the empty state by itself; pass { status: "empty", title, description, action } to give it your wording.

Default –
tableNexera
ChartTableOptions

The data table that is the text alternative: caption, first-column header and whether it is visible or only for assistive technology.

Default –
localeNexera
string

Locale of digits and separators.

Default the `NexeraProvider` locale
valueFormatNexera
NumberFormatOptions

Intl.NumberFormat options for values ({ style: "currency", currency: "PKR" }, { style: "percent" }). Serialisable, so it works from a Server Component; formatValue needs a Client Component.

Default –
formatValueNexera
(value: number) => string

Formats a value for tooltips, point labels and the table (full precision). Wins over valueFormat.

Default –
formatAxisValueNexera
(value: number) => string

Formats an axis tick (short: "29M").

Default the compact notation of `valueFormat`
heightNexera
number

Height of the plot in px. The card grows with the header, KPI and legend around it.

Default 258
plotLabelNexera
string

Accessible name of the plot group. Translate it.

Default the chart `title`
noDataLabelNexera
string

Text for a missing value in the tooltip and the table. Translate it.

Default No data

* Required. React Aria props shown are the ones most apps use; the component accepts the rest of its React Aria props too.

Accessible by default.

Built on React Aria, and covered by the WCAG 2.2 evidence generated on every build.

WCAG 2.2 evidence

7 direct · 1 supporting
  • 1.1.1Non-text ContentLevel A · tested directly
  • 1.3.1Info and RelationshipsLevel A · tested directly
  • 1.4.10ReflowLevel AA · tested directly
  • 1.4.13Content on Hover or FocusLevel AA · tested directly
  • 2.1.1KeyboardLevel A · tested directly
  • 2.3.3Animation from InteractionsLevel AAA · supporting test
  • 4.1.2Name, Role, ValueLevel A · tested directly
  • 4.1.3Status MessagesLevel AA · tested directly

Fits any width.

Nexera components respond to the space they are given. Drag the corner of the frame, or pick a width.

0 px · drag the corner

Styling hooks

Pass className to add Tailwind classes (merged last). State is exposed as data attributes, so you can style it with variants like data-pressed:.

Usage
<HistogramChart className="shadow-sm" />

Used in blocks

Related components