Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Chart Type Command Menu Block for React

A report builder's chart-type menu rising from the foot of a drawn report: eight types with tiny glyphs, a band that redraws one typed series as the chosen chart in hand-built SVG, a sentence and a list of figures for each, and a Stacked switch for bar and area.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

Try a chart type on your own numbers before you commit to it with this chart type command menu for React with Base UI. It rises from the foot of the Report panel of Plotwren, a report builder, whose header holds an outline field with its ⌘ K cap, and the report is drawn under a soft scrim inside a hairline frame with a plus mark on each corner: a title bar, a chart card and a toolbar whose chip names the chart type. The menu is the catalog Command with eight types in two groups, Basic (Line, Area, Bar and Step) and Advanced (Scatter, Heatmap, Funnel and Radar), each a tiny glyph with a one-line hint. A band at the top of the menu draws the chosen type from one typed series, seven days of visits for this week and last, and Enter redraws it, and the report behind the menu, as that chart while the menu stays open, so you can try one type after another. A Stacked switch beside the chart works for Bar and Area; for the other types its row is held in place, unavailable, so nothing moves. Every chart is hand-built SVG in foreground weights, this week solid and last week lighter, with a sentence beside it that says what it shows and a list of the figures for assistive technology. For preview the menu is drawn open in place when the page loads; the field, or Ctrl or ⌘ K while focus is in the block, opens the real command dialog with the same chart and query. For report builders, dashboards and any product with a chart picker.

FAQ

Why is the menu already open, and what do I keep?

So you can see it without a click. On load the menu is the Command with its chart band drawn inline over a picture of the report, in a plain shell that is not modal, so nothing is trapped, hidden or focused and the page around the preview keeps working. The header's field opens the real command dialog, modal, with its focus trap, Escape and focus return, and the inline copy stays closed until a reload. Both show the same Palette and share the block's state, so the chart chosen in the copy is the one the dialog opens with. In your app keep the dialog and drop the copy: the "in-place" state, the scrim with its shell and the Escape and blur effects.

Where do the charts get their data?

From one typed series at the top of the block, seven days of visits for this week and last week, so every type draws the same numbers and you can compare how each shows them: lines, steps and areas along the days, bars in pairs or stacked, scatter points, a two-row heatmap shaded by visits, a funnel of this week's days from busiest to quietest, and a radar with a spoke for each day. The geometry is plain module-scope functions that turn values into path data and rectangles, with no chart library. In your app pass your own series and keep the geometry.

How is it read without seeing it?

The drawing is hidden from assistive technology and replaced by two things: a sentence beside it that says what the chart shows ("Seven pairs of bars. This week is highest on Sat at 640 and lowest on Tue at 310"), and a list of the figures, one line a day ("Mon: this week 320, last week 280"). The sentence changes with the type and with Stacked. The chart's days run the same way in any page direction, as a time axis should.

What does Stacked do?

For Bar it stacks last week's bar on this week's in one column per day, and for Area it stacks last week's area on this week's, rescaling the axis so the total fits. For the other types the switch row is still there but unseen and inert, so the band never changes height, and the status line says nothing when it can't apply. The setting is remembered when you move to another type and back.

What stays local, and how do I wire it?

All of it. The series, the chosen type and the switch are typed state in the block; nothing is saved and nothing leaves the page. In your app replace THIS and LAST with your data, write the type and the switch to the selected chart in pick, and keep the band as the preview.

Is it accessible from the keyboard?

Yes. Type to search by name, hint or word ("trend", "bar", "scatter", "shade"), the arrow keys move through the types, Enter draws the highlighted one and keeps focus in the input, and Escape closes the menu and puts focus on the field; Tab reaches the Stacked switch. Ctrl or ⌘ K opens the dialog while focus is inside the block, and only then. The rows are options of a cmdk listbox; the block turns off its own fuzzy filter and lists the rows itself. A tick and the words ", drawn now" mark the type on show.

How does it look on a phone?

The chart is hidden and the band shrinks to one line of text ("Line chart, seven days. This week peaks on Sat at 640") with the Stacked switch under it; the figures stay in the list for screen readers. The copy shown on load docks to the top of the page at full width, so the keyboard does not cover the foot; the key hints go and the count stays. The real dialog keeps the Command dialog's own phone layout.

  • Pro

    A motion tool's preset menu shown open over its transitions panel: easing curves, springs and durations each drawn as a 24 px curve, a track band that runs the highlighted preset's real CSS timing once on an arrow key or Replay, and a text reading under reduced motion.

  • Pro

    A design tool's tone picker as a command menu shown open over its Fill row: an eleven-step grey ramp and recent tones, a HEX, RGB or HSL switch that rewrites every value and what Enter copies, and a band with the highlighted tone's contrast on white and on black.

  • Pro

    A dashboard configurator's layout switcher as a command menu docked at the end of the page: six layouts each with a greyscale diagram, a band that draws the highlighted one larger, and Enter to re-arrange the drawn dashboard, still under reduced motion.

  • Pro

    A dashboard app's appearance menu shown open beside a live mini app: mode, corner radius, density and text size in four groups with a tick on each current choice, and a preview that restyles the moment you choose while the menu stays open.

  • Pro

    A design-system inspector's token picker as a command menu hung from a Fill field: tokens in groups with their resolved values and a small drawing, a box pane that wears whatever you apply, the alias chain of the last token, and a copy as CSS variable or JSON.

  • Pro

    A team chat's emoji menu shown open over its composer: names and shortcodes, a skin-tone switch for hands and people, and Enter adds an emoji to the message under the list while the menu stays open.