Bar chart
Values across categories as bars: side by side, stacked or as shares, vertical or horizontal, or as a bridge from a start to an end. The hovered category stays bright while the rest dims, and every change of data, range or sort glides from where the bars are.
Examples
Stacked
stack puts the series side by side, stacked, or as shares of their total. A new range, a sort or a hidden series glides from where the bars are, and new data grows out of the loading placeholder.
Synced
Charts in a ChartGroup share the category under the pointer or the focus, by its key.
Bridge
With layout="bridge", each change floats from the running total before it, and the categories in totals stand on the axis: given, or worked out when they have no value.
Ribbons
With ribbons, each series flows from one stack to the next, so a part’s growth reads across the categories. Pointing at a ribbon or a bar brings that series forward.
Horizontal
orientation='horizontal' lays the bars along the categories, here with each value written past its bar and a target line.
Negative values
Bars below zero hang from it, in negativeColor when you give one.
Tracks
track draws each bar’s whole length behind it, for values out of a whole, and label='inside' writes the value at the bar’s end.
Picking a category
selected, defaultSelected or onSelectedChange lets a press, Enter or Space pick a category, which stays bright until another is picked.
Timeline
indexType='time' places each bar on its date, as wide as the closest two allow, so the days with no deploys stay empty.
Reference lines and bands
ChartReferenceLine marks a value, one worked out from the data such as the average, or a category; ChartReferenceArea shades a range. The value axis reaches far enough to show them.
Patterns
patterns gives each series after the first a pattern over its colour, so the series differ by more than colour. The legend shows and hides them.
Overlap
stack="overlap" stands the series of one stack in front of one another, each from the axis, the first written at the back: here each month’s hours booked in front of the hours the team has. It suits a part that never passes its whole; two values that can pass each other read better side by side, with a barGap below zero.
Previous period
A barGap below zero overlaps the bars side by side, so each day stands just in front of the same day last week. Today, still coming in, is a series of its own in --chart-accent, solid so far with its pace behind it; the other days leave its keys out, so the tooltip leaves it out there.
Axis titles
An axis takes a label, and side puts it at either edge: here the values sit at the end.
Error
error says the data couldn’t load, and onRetry adds a button that tries again. loading shows a placeholder the bars grow out of.
Installation
npx shadcn@latest add https://kinoui.com/r/bar-chart.json- Files
lib/dates.tslib/chart-math.tslib/chart-scale.tslib/chart-frame.tslib/chart-bar-marks.tslib/refs.tslib/reduce-motion.tslib/resize.tslib/live.tsxlib/chart-live.tslib/chart-live-clock.tsxlib/scroll.tslib/swap.tsxlib/popup.tslib/glide.tsxlib/keys.tsxcomponents/kino/kbd.tsxcomponents/kino/tooltip.tsxlib/cut.tsxlib/number-format.tslib/roll.tsxlib/run-progress.tscomponents/kino/animated-number.tsxlib/announce.tscomponents/kino/spinner.tsxcomponents/kino/button.tsxlib/controllable.tslib/chart-root.tsxlib/chart-state.tslib/chart-agent.tslib/chart-base.tsxlib/chart-cartesian-reader.tslib/chart-cartesian.tsxlib/chart-list.tsxlib/chart-list-reader.tslib/chart-tree-reader.tslib/chart-flow-reader.tslib/chart-grid-reader.tslib/highlight.tscomponents/kino/chart.tsxlib/placeholder.tslib/chart-bars.tsxcomponents/kino/bar-chart.tsx- Packages
@ui-sdk/core@ui-sdk/reactclass-variance-authorityd3-array- Global CSS
- the feels, the density tokens, the shape tokens and the success and warning colours
New to Kino? Installation covers what your project needs first and the @kino namespace.
The CLI keeps any of these colours your project already has, such as the chart colours shadcn init writes. To use Kino’s, set them in your global CSS:
:root { --chart-1: oklch(0.42 0.1 248); --chart-2: oklch(0.53 0.12 222); --chart-3: oklch(0.6 0.11 185); --chart-4: oklch(0.65 0.17 132); --chart-5: oklch(0.72 0.154 106.7); --chart-accent: oklch(0.795 0.171 71.2);}.dark { --chart-1: oklch(0.6 0.15 255); --chart-2: oklch(0.7 0.13 222); --chart-3: oklch(0.79 0.13 185); --chart-4: oklch(0.82 0.15 128); --chart-5: oklch(0.72 0.154 106.7); --chart-accent: oklch(0.795 0.171 71.2);}API reference
BarChart
The chart: a <figure> named by label, holding the chart’s parts. Other props go to the figure. The props from data to messages are the same on every chart.
Bar
One series’ bars, in its colour. Other props go to its layer. A missing value shows a short dashed mark at zero, so it reads apart from a zero.
BarTotals
Each category’s total, written past the end of its stack. Takes format, the chart’s by default.
ChartGrid
Dashed lines across the plot at the value axis’s ticks, and on a chart whose x is a value too, such as the Scatter chart, along it at the x axis’s ticks. They slide when the range changes.
ChartYAxis
The axis beside the plot: values for upright bars, categories for lying ones, and on a grid of cells, such as the Heatmap chart, its rows. Where its names are taller than their rows, every few show. Other props go to its <div>.
ChartXAxis
The axis under the plot: categories for upright bars, values for lying ones, x values on a chart whose x is a value too, such as the Scatter chart, times on a chart whose indexType is time, and the columns of a grid of cells, such as the Heatmap chart’s hours or months. A pill glides to the name of the category, or the time, under the pointer. Times get calendar ticks, as many as fit, each saying only what changed at it (14:00, 17 Nov, Dec, 2027). On a live chart, its ticks and pill scroll with the plot and fade at its ends. Other props go to its <div>.
ChartTooltip
What is under the pointer or the focus, in the chart’s own words: on a chart with series, the values of the category or the time. It shows at once and slides from one to the next. Other props go to its popup.
ChartTooltipContent
The category’s name, then a row for each shown series, with its change when the chart is ordered. On an x of times, a series with no row at that time shows its nearest one within half the smaller of its own usual gap and the chart’s rows’, with that row’s time, and is left out past it. Takes index, total and hideLabel.
ChartLegend
A toggle for each series that shows and hides it. Pointing at one, or focusing it, brings its series forward. Takes position, top or bottom.
ChartReferenceLine
A dashed line across the plot. Like every part the range reaches for, it sits straight inside the chart, or in a fragment there, so the chart reads it as it renders, in a file marked use client. Other props go to its layer.
ChartReferenceArea
A band from from to to on the value axis, such as a goal, named by label at its far end. With axis, a band on another value axis a series names, or with axis='x', between two x values on a chart whose x is a value too.
ChartGroup
Charts inside it share the category under the pointer or the focus, by its key, so pointing at a day on one lights it on all of them.
Data attributes
CSS variables
Accessibility
- The plot is one stop in the tab order: a slider over the categories. The arrow keys step, Home and End go to the ends, and each category’s values are read as the slider’s value.
- A hidden table holds every value, for screen readers and for copying.
- A bridge says each change in words, such as “down 4,900, running total 34,000”, so a rise and a fall never rest on colour alone, and its table gives each change and running total.
- With
ribbons, the up and down arrows step through the stack’s parts (the arrows along the bars when they lie), and each part is read alone, with its change since the category before. - Loading, an error and new data are announced in a status region.
- With
patterns, each series after the first has a pattern as well as its colour, and forced colours draw each series in a system colour. - When the system asks for less motion, bars and labels move to their place at once and only fade.
- On an x of times, what is read out at a stop gives each series’ nearest row as the tooltip does, with that row’s time, while the table shows only the rows at each time.
- The chart is a
<figure>named bylabel. - Escape closes the tooltip and nothing above the chart.
- The legend’s toggles say whether each series shows. When every series is hidden, a button shows them all again and takes the focus.
For agents
What an agent reads on this example with snapshot(), and the actions it can call with act().
The Agent bridge page sets up snapshot() and act() in your app.