Skip to main content

UI Components

This guide explains how to build custom widgets using the UI component library provided by @openuidev/react-ui.

The package was previously named @crayonai/react-ui. Both names refer to the same project, but the rename introduced some breaking changes. When upgrading an older widget, review the Widgets FAQ for migration guidance.

Component index​

The following table lists the available components by category.

GroupComponents
LayoutCard, CardHeader, Separator
ActionsButton, Buttons, IconButton
TextTextContent, MarkDownRenderer, TextCallout, Callout, CodeBlock
TagsTag, TagBlock
ListsListBlock, ListItem, FollowUpBlock, FollowUpItem
StepsSteps, StepsItem
DisclosureAccordion, AccordionItem, AccordionTrigger, AccordionContent, Tabs, TabsList, TabsTrigger, TabsContent
MediaImage, ImageBlock, ImageGallery, Carousel, CarouselContent, CarouselItem, CarouselPrevious, CarouselNext
TableTable, ScrollableTable, TableHeader, TableBody, TableFooter, TableRow, TableHead, TableCell
Form inputsFormControl, Label, Hint, Input, TextArea, Select, SelectTrigger, SelectValue, SelectContent, SelectGroup, SelectLabel, SelectItem, SelectSeparator
ChoicesCheckBoxGroup, CheckBoxItem, RadioGroup, RadioItem, SwitchGroup, SwitchItem
RangeSlider, SliderBlock
DatesCalendar, DatePicker
ChartsLineChart, BarChart, AreaChart, ScrollableLineChart, ScrollableBarChart, ScrollableAreaChart, HorizontalBarChart, PieChart, RadialChart, SingleStackedBar, RadarChart, ScatterChart, MiniLineChart, MiniBarChart, MiniAreaChart

Shared prop vocabulary:

  • variant on containers (Card, Accordion, CheckBoxGroup, RadioGroup, SwitchGroup, TextContent, MarkDownRenderer): "card" (bordered surface), "sunk" (recessed fill) or "clear" (no chrome).
  • Status variant (Tag, TextCallout, Callout): "neutral" | "info" | "success" | "warning" | "danger".
  • Most components also accept className and style. CardHeader, Image, Input and Tag take styles instead.

Layout​

UI.Card — the standard surface. It accepts every <div> attribute.

PropTypeDefault
variant"card" \| "sunk" \| "clear""card"
width"standard" \| "full""standard"

UI.CardHeader — title row for a card.

PropTypeNotes
titlenode
subtitlenode
iconnodee.g. <Icons.User size={16} />
actionsButton / IconButton element or arrayright-aligned
stylesCSS objectnote: styles, not style

UI.Separator — horizontal rule (Radix Separator). Pass orientation="vertical" inside a flex row.

Example Code​

function ProfileCard(props) {
const { name, role, bio } = props;
return (
<UI.Card variant="card" width="standard">
<UI.CardHeader
icon={<Icons.User size={16} />}
title={name}
subtitle={role}
actions={<UI.IconButton icon={<Icons.MoreHorizontal size={14} />} variant="tertiary" size="small" aria-label="More" />}
/>
<UI.Separator />
<p style={{ margin: "12px 0 0", color: "var(--foreground, #111827)" }}>{bio}</p>
</UI.Card>
);
}
module.exports.default = ProfileCard;

Example Data​

{ "name": "Priya Shah", "role": "Account manager", "bio": "Looks after enterprise renewals in APAC." }

Actions​

UI.Button — accepts every <button> attribute.

PropTypeDefault
variant"primary" \| "secondary" \| "tertiary""primary"
size"extra-small" \| "small" \| "medium" \| "large""medium"
buttonType"normal" \| "destructive""normal"
iconLeft / iconRightnode

UI.Buttons — lays out a group of Button/IconButton children. variant: "horizontal" (default) or "vertical".

UI.IconButton — square or round icon-only button. Give it an aria-label.

PropTypeDefault
iconnode (required)
variant"primary" \| "secondary" \| "tertiary""primary"
size"3-extra-small" \| "2-extra-small" \| "extra-small" \| "small" \| "medium" \| "large""medium"
shape"square" \| "circle""square"
appearance"normal" \| "destructive""normal"

Use the submit prop to send the user's choice back to the agent:

Example Code​

function ConfirmOrder(props) {
const { orderId, submit } = props;
const send = (message) => submit && submit({ title: "Order " + orderId, message: message });
return (
<UI.Card variant="card">
<UI.CardHeader title={"Confirm order " + orderId + "?"} />
<UI.Buttons variant="horizontal">
<UI.Button variant="primary" iconLeft={<Icons.Check size={14} />} onClick={() => send("Confirm order " + orderId)}>
Confirm
</UI.Button>
<UI.Button variant="secondary" onClick={() => send("Change order " + orderId)}>Change</UI.Button>
<UI.Button variant="tertiary" buttonType="destructive" onClick={() => send("Cancel order " + orderId)}>
Cancel
</UI.Button>
</UI.Buttons>
</UI.Card>
);
}
module.exports.default = ConfirmOrder;

Example Data​

{ "orderId": "A-1042" }

Text​

UI.TextContent — a block of body text. variant: "clear" | "card" | "sunk".

UI.MarkDownRenderer — renders a markdown string.

PropTypeNotes
textMarkdownstring (required)
variant"clear" \| "card" \| "sunk"
optionsreact-markdown Optionsadvanced

The MarkdownText global is the app's own markdown renderer (the one chat uses). Use it when the text should match the surrounding chat messages.

UI.TextCallout / UI.Callout — highlighted message boxes. TextCallout is the compact inline form.

PropType
variant"neutral" \| "info" \| "success" \| "warning" \| "danger"
titlenode
descriptionnode

UI.CodeBlock — syntax-highlighted code.

PropType
languagestring (required), e.g. "json", "python"
codeStringstring (required)

Example Code​

function ReleaseNote(props) {
const { version, summary, notes, snippet } = props;
return (
<UI.Card variant="card">
<UI.CardHeader title={"Release " + version} />
<UI.TextContent variant="clear">{summary}</UI.TextContent>
<UI.MarkDownRenderer variant="sunk" textMarkdown={notes} />
<UI.TextCallout variant="warning" title="Heads up" description="Tokens issued before this release expire in 7 days." />
<UI.Callout variant="success" title="No downtime" description="The rollout is incremental." />
<UI.CodeBlock language="json" codeString={snippet} />
</UI.Card>
);
}
module.exports.default = ReleaseNote;

Example Data​

{
"version": "2.4.0",
"summary": "Faster sync and a new export format.",
"notes": "- **Sync** is 2x faster\n- New `csv` export",
"snippet": "{\n \"export\": \"csv\"\n}"
}

Tags​

UI.Tag — a small pill.

PropTypeDefault
textnode (required)
variant"neutral" \| "info" \| "success" \| "warning" \| "danger""neutral"
size"sm" \| "md" \| "lg""md"
iconnode
stylesCSS object

UI.TagBlock — wraps a row of Tags.

Example Code​

function TicketTags(props) {
const { status, labels } = props;
const statusVariant = status === "Open" ? "warning" : status === "Resolved" ? "success" : "neutral";
return (
<UI.TagBlock>
<UI.Tag text={status} variant={statusVariant} icon={<Icons.Circle size={10} />} />
{(labels || []).map((l) => <UI.Tag key={l} text={l} size="sm" />)}
</UI.TagBlock>
);
}
module.exports.default = TicketTags;

Example Data​

{ "status": "Open", "labels": ["billing", "priority"] }

Lists​

UI.ListBlock — a list of ListItems. It numbers the items and passes variant down to every item.

PropTypeDefault
variant"number" \| "icon" \| "image""number"

UI.ListItem

PropTypeNotes
titlenode
subtitlenode
iconnodeshown when the block variant="icon"
image{ src, alt }shown when the block variant="image"
actionLabel / actionIconnodetrailing affordance
onClick() => voidmakes the row clickable

UI.FollowUpBlock / UI.FollowUpItem — suggested next questions. FollowUpItem takes text (required) and icon, plus button attributes such as onClick.

Example Code​

function TopArticles(props) {
const { articles, suggestions, submit } = props;
return (
<UI.Card variant="card">
<UI.CardHeader title="Top articles" />
<UI.ListBlock variant="icon">
{articles.map((a) => (
<UI.ListItem
key={a.title}
title={a.title}
subtitle={a.views + " views"}
icon={<Icons.FileText size={14} />}
actionIcon={<Icons.ChevronRight size={14} />}
onClick={() => submit && submit({ message: "Open article: " + a.title })}
/>
))}
</UI.ListBlock>
<UI.FollowUpBlock>
{suggestions.map((s) => (
<UI.FollowUpItem key={s} text={s} onClick={() => submit && submit({ message: s })} />
))}
</UI.FollowUpBlock>
</UI.Card>
);
}
module.exports.default = TopArticles;

Example Data​

{
"articles": [
{ "title": "Reset your password", "views": 1240 },
{ "title": "Set up SSO", "views": 860 }
],
"suggestions": ["Show more articles", "Which ones are outdated?"]
}

Steps​

UI.Steps numbers its StepsItem children automatically. UI.StepsItem takes title and details (both required), plus an optional number that overrides the automatic number.

Example Code​

function SetupGuide(props) {
const { steps } = props;
return (
<UI.Steps>
{steps.map((s) => <UI.StepsItem key={s.title} title={s.title} details={s.details} />)}
</UI.Steps>
);
}
module.exports.default = SetupGuide;

Example Data​

{
"steps": [
{ "title": "Create an API key", "details": "Settings → API keys → New key." },
{ "title": "Add the webhook", "details": "Paste the URL into your CRM." },
{ "title": "Send a test event", "details": "Use the Test button to verify." }
]
}

Disclosure​

Accordion (Radix Accordion): UI.Accordion → UI.AccordionItem → UI.AccordionTrigger + UI.AccordionContent.

ComponentProps
Accordiontype: "single" | "multiple" (required); collapsible (single only); defaultValue; variant: "card" \| "sunk" \| "clear"
AccordionItemvalue (required, unique)
AccordionTriggertext (required), icon
AccordionContentchildren

Tabs (Radix Tabs): UI.Tabs → UI.TabsList with UI.TabsTriggers, then one UI.TabsContent per tab.

ComponentProps
TabsdefaultValue or value + onValueChange; variant: "clear" only
TabsListvariant: "title" | "iconTitle" | "iconTitleSubtext" | "imageTitle" | "imageTitleSubtext"
TabsTriggervalue and text (required); icon, subtext, image (URL)
TabsContentvalue (required)

Example Code​

function PlanDetails(props) {
const { faqs, monthly, yearly } = props;
return (
<UI.Card variant="card">
<UI.Tabs defaultValue="monthly">
<UI.TabsList variant="iconTitle">
<UI.TabsTrigger value="monthly" text="Monthly" icon={<Icons.Calendar size={14} />} />
<UI.TabsTrigger value="yearly" text="Yearly" icon={<Icons.CalendarRange size={14} />} />
</UI.TabsList>
<UI.TabsContent value="monthly"><UI.TextContent>{monthly}</UI.TextContent></UI.TabsContent>
<UI.TabsContent value="yearly"><UI.TextContent>{yearly}</UI.TextContent></UI.TabsContent>
</UI.Tabs>
<UI.Accordion type="single" collapsible variant="clear">
{faqs.map((f, i) => (
<UI.AccordionItem key={i} value={"faq-" + i}>
<UI.AccordionTrigger text={f.q} icon={<Icons.HelpCircle size={14} />} />
<UI.AccordionContent>{f.a}</UI.AccordionContent>
</UI.AccordionItem>
))}
</UI.Accordion>
</UI.Card>
);
}
module.exports.default = PlanDetails;

Example Data​

{
"monthly": "$29 / month, cancel anytime.",
"yearly": "$290 / year — two months free.",
"faqs": [
{ "q": "Can I switch plans later?", "a": "Yes, changes apply on the next billing cycle." },
{ "q": "Is there a free trial?", "a": "14 days, no card required." }
]
}

Media​

UI.Image — accepts every <img> attribute.

PropTypeNotes
srcstring (required)
altstring
aspectRatio"1:1" \| "3:2" \| "3:4" \| "4:3" \| "16:9"
scale"fit" \| "fill"
stylesCSS object

UI.ImageBlock — a single image with a loading state: src (required), alt, imageLoading.

UI.ImageGallery — a thumbnail grid that opens a full-screen viewer. images: [{ src, alt?, details? }].

Carousel — UI.Carousel → UI.CarouselContent → UI.CarouselItems, followed by UI.CarouselPrevious / UI.CarouselNext. The prev/next buttons render only when there is room to scroll, and each needs an icon.

ComponentProps
Carouselvariant: "card" \| "sunk"; itemsToScroll (default 1); showButtons (default true); noSnap
CarouselPrevious / CarouselNexticon (required), plus IconButton props

Example Code​

function ProductShowcase(props) {
const { products, gallery } = props;
return (
<UI.Card variant="card" width="full">
<UI.Carousel variant="card" itemsToScroll={1}>
<UI.CarouselContent>
{products.map((p) => (
<UI.CarouselItem key={p.name}>
<UI.Image src={p.image} alt={p.name} aspectRatio="4:3" scale="fill" />
<div style={{ fontWeight: 600, marginTop: 8 }}>{p.name}</div>
<div style={{ color: "var(--muted-foreground, #6b7280)" }}>{p.price}</div>
</UI.CarouselItem>
))}
</UI.CarouselContent>
<UI.CarouselPrevious icon={<Icons.ChevronLeft size={14} />} />
<UI.CarouselNext icon={<Icons.ChevronRight size={14} />} />
</UI.Carousel>
<UI.ImageBlock src={products[0].image} alt={products[0].name} />
<UI.ImageGallery images={gallery} />
</UI.Card>
);
}
module.exports.default = ProductShowcase;

Example Data​

{
"products": [
{ "name": "Desk lamp", "price": "$39", "image": "https://picsum.photos/seed/lamp/400/300" },
{ "name": "Chair", "price": "$149", "image": "https://picsum.photos/seed/chair/400/300" },
{ "name": "Monitor arm", "price": "$89", "image": "https://picsum.photos/seed/arm/400/300" }
],
"gallery": [
{ "src": "https://picsum.photos/seed/g1/600/400", "alt": "Front", "details": "Front view" },
{ "src": "https://picsum.photos/seed/g2/600/400", "alt": "Side" }
]
}

Table​

The parts mirror HTML tables: UI.Table → UI.TableHeader / UI.TableBody / UI.TableFooter → UI.TableRow → UI.TableHead (header cell) or UI.TableCell.

ComponentExtra props
TablecontainerClassName, containerStyle (the wrapper scrolls horizontally)
ScrollableTablethe same; use it for wide tables in narrow chat columns
TableHeadicon, align: "left" \| "center" \| "right"
TableCellalign: "left" \| "center" \| "right" (right-align numbers)

Example Code​

function InvoiceTable(props) {
const { rows, total } = props;
return (
<UI.Table>
<UI.TableHeader>
<UI.TableRow>
<UI.TableHead>Item</UI.TableHead>
<UI.TableHead align="right">Qty</UI.TableHead>
<UI.TableHead align="right">Amount</UI.TableHead>
</UI.TableRow>
</UI.TableHeader>
<UI.TableBody>
{rows.map((r) => (
<UI.TableRow key={r.item}>
<UI.TableCell>{r.item}</UI.TableCell>
<UI.TableCell align="right">{r.qty}</UI.TableCell>
<UI.TableCell align="right">{r.amount}</UI.TableCell>
</UI.TableRow>
))}
</UI.TableBody>
<UI.TableFooter>
<UI.TableRow>
<UI.TableCell colSpan={2}>Total</UI.TableCell>
<UI.TableCell align="right">{total}</UI.TableCell>
</UI.TableRow>
</UI.TableFooter>
</UI.Table>
);
}
module.exports.default = InvoiceTable;

Example Data​

{
"rows": [
{ "item": "Pro seats", "qty": 12, "amount": "$348" },
{ "item": "Voice minutes", "qty": 3000, "amount": "$90" }
],
"total": "$438"
}

Form inputs​

Widget inputs keep local state. Nothing reaches the agent until you call submit(...).

ComponentProps
FormControlgroups label + control + hint; hasError turns the hint red
Labelchildren (required), required, disabled, htmlFor
Hinthelper or error text; inherits hasError from FormControl
Inputevery <input> attribute; size: "small" \| "medium" \| "large"; hasError
TextAreaevery <textarea> attribute; rows; hasError
SelectRadix Select root: value / defaultValue, onValueChange; size: "sm" \| "md" \| "lg"
SelectTriggerwraps SelectValue; size, hideDropdownIcon
SelectValueplaceholder
SelectContentthe dropdown (portalled; it follows the theme automatically)
SelectGroup / SelectLabel / SelectSeparatorgrouping
SelectItemvalue (required), children, showTick

Example Code​

function CallbackForm(props) {
const { topics, submit } = props;
const [phone, setPhone] = useState("");
const [topic, setTopic] = useState("");
const [note, setNote] = useState("");
const phoneError = phone.length > 0 && phone.replace(/\D/g, "").length < 10;
const send = () =>
submit && submit({ title: "Callback request", message: "Call me at " + phone + " about " + topic + ". " + note });
return (
<UI.Card variant="card">
<UI.CardHeader title="Request a callback" />
<UI.FormControl hasError={phoneError}>
<UI.Label htmlFor="cb-phone" required>Phone</UI.Label>
<UI.Input id="cb-phone" placeholder="+1 555 010 0000" value={phone} onChange={(e) => setPhone(e.target.value)} hasError={phoneError} />
<UI.Hint>{phoneError ? "Enter at least 10 digits" : "We call within one business day"}</UI.Hint>
</UI.FormControl>
<UI.FormControl>
<UI.Label>Topic</UI.Label>
<UI.Select value={topic} onValueChange={setTopic}>
<UI.SelectTrigger>
<UI.SelectValue placeholder="Choose a topic" />
</UI.SelectTrigger>
<UI.SelectContent>
<UI.SelectGroup>
<UI.SelectLabel>Topics</UI.SelectLabel>
{topics.map((t) => <UI.SelectItem key={t} value={t}>{t}</UI.SelectItem>)}
</UI.SelectGroup>
</UI.SelectContent>
</UI.Select>
</UI.FormControl>
<UI.FormControl>
<UI.Label>Notes</UI.Label>
<UI.TextArea rows={3} value={note} onChange={(e) => setNote(e.target.value)} placeholder="Anything we should know?" />
</UI.FormControl>
<UI.Button disabled={!phone || phoneError || !topic} onClick={send}>Request callback</UI.Button>
</UI.Card>
);
}
module.exports.default = CallbackForm;

Example Data​

{ "topics": ["Billing", "Technical issue", "Sales"] }

Choices​

ComponentProps
CheckBoxGroupvariant: "card" \| "sunk" \| "clear"; children are CheckBoxItems
CheckBoxItemlabel, description, checked / defaultChecked, onChange(checked: boolean), name, value, disabled
RadioGroupRadix RadioGroup: value / defaultValue, onValueChange(value), variant
RadioItemvalue (required), label, description, disabled
SwitchGroupvariant; children are SwitchItems
SwitchItemlabel, description, checked / defaultChecked, onChange(checked: boolean), disabled

Note: CheckBoxItem and SwitchItem call onChange with a boolean, not a DOM event.

Example Code​

function NotificationPrefs(props) {
const { channels, submit } = props;
const [selected, setSelected] = useState([]);
const [frequency, setFrequency] = useState("daily");
const [muted, setMuted] = useState(false);
const toggle = (c, on) => setSelected((prev) => (on ? prev.concat(c) : prev.filter((x) => x !== c)));
const save = () =>
submit && submit({ message: "Notify me via " + (selected.join(", ") || "nothing") + ", " + frequency + (muted ? ", muted on weekends" : "") });
return (
<UI.Card variant="card">
<UI.CardHeader title="Notification preferences" />
<UI.CheckBoxGroup variant="clear">
{channels.map((c) => (
<UI.CheckBoxItem key={c} label={c} checked={selected.includes(c)} onChange={(on) => toggle(c, on)} />
))}
</UI.CheckBoxGroup>
<UI.RadioGroup value={frequency} onValueChange={setFrequency} variant="clear">
<UI.RadioItem value="instant" label="Instant" />
<UI.RadioItem value="daily" label="Daily digest" description="One email at 9am" />
</UI.RadioGroup>
<UI.SwitchGroup variant="clear">
<UI.SwitchItem label="Mute on weekends" checked={muted} onChange={setMuted} />
</UI.SwitchGroup>
<UI.Button onClick={save}>Save</UI.Button>
</UI.Card>
);
}
module.exports.default = NotificationPrefs;

Example Data​

{ "channels": ["Email", "SMS", "Slack"] }

Slider, SliderBlock​

UI.Slider — the bare track (Radix Slider). Values are always arrays: one number for a single thumb, two for a range.

PropTypeNotes
variant"continuous" \| "discrete" (required)discrete shows step dots
min, maxnumber (required)
stepnumber
value / defaultValuenumber[]
onValueChange / onValueCommit(value: number[]) => void
leftContent / rightContentnodee.g. icons

UI.SliderBlock — a labelled slider with editable number inputs. It takes the same props plus label (required) and manages its own value. Listen with onValueCommit.

Example Code​

function BudgetPicker(props) {
const { min, max, submit } = props;
const [seats, setSeats] = useState([10]);
return (
<UI.Card variant="card">
<UI.CardHeader title={"Seats: " + seats[0]} />
<UI.Slider
variant="continuous"
min={1}
max={100}
step={1}
value={seats}
onValueChange={setSeats}
leftContent={<Icons.User size={12} />}
rightContent={<Icons.Users size={12} />}
/>
<UI.SliderBlock
label="Budget range ($)"
variant="continuous"
min={min}
max={max}
step={100}
defaultValue={[min, max]}
onValueCommit={(v) => submit && submit({ message: "Budget between $" + v[0] + " and $" + v[1] })}
/>
</UI.Card>
);
}
module.exports.default = BudgetPicker;

Example Data​

{ "min": 500, "max": 5000 }

Dates​

UI.Calendar — an inline calendar built on react-day-picker v9. It takes all DayPicker props, most importantly:

PropNotes
mode"single" \| "multiple" \| "range"
selectedDate, Date[] or { from, to }, matching mode
onSelectcalled with the new selection
disabledmatcher, e.g. { before: new Date() }

Props arrive as JSON, so dates are strings. Convert them with new Date(str) before passing them in.

UI.DatePicker — a calendar with a dropdown header, single or range.

PropType
mode"single" \| "range"
selectedSingleDate / setSelectedSingleDateDate and its setter (single mode)
selectedRangeDates / setSelectedRangeDates{ from, to } and its setter (range mode)

Example Code​

function BookingDates(props) {
const { busyDays, submit } = props;
const [day, setDay] = useState();
const [range, setRange] = useState();
const busy = (busyDays || []).map((d) => new Date(d));
return (
<UI.Card variant="card">
<UI.CardHeader title="Pick a day" subtitle="Highlighted days are fully booked" />
<UI.Calendar mode="multiple" selected={busy} />
<UI.DatePicker mode="single" selectedSingleDate={day} setSelectedSingleDate={setDay} />
<UI.DatePicker mode="range" selectedRangeDates={range} setSelectedRangeDates={setRange} />
<UI.Button
disabled={!day}
onClick={() => submit && submit({ message: "Book " + day.toDateString() })}
>
Book
</UI.Button>
</UI.Card>
);
}
module.exports.default = BookingDates;

Example Data​

{ "busyDays": ["2026-11-03", "2026-11-04", "2026-11-10"] }

Charts​

Charts use a flat rows data contract. It is not Chart.js: there is no labels, datasets or options, and those props are silently ignored, so you get empty axes.

Which chart​

ComponentUse forData contract
LineChart, BarChart, AreaCharttrends and comparisons over categories; they fit the container widthrows + categoryKey
ScrollableLineChart, ScrollableBarChart, ScrollableAreaChartlong series (dozens of points); they scroll horizontally instead of squeezingrows + categoryKey
HorizontalBarChartranked lists with long labelsrows + categoryKey
PieChartpart-to-whole (variant="donut" for a donut)rows + categoryKey + dataKey
RadialChartpart-to-whole as rings or a gaugerows + categoryKey + dataKey
SingleStackedBarpart-to-whole as one horizontal barrows + categoryKey + dataKey
RadarChartcomparing several metrics per categoryrows + categoryKey
ScatterChartcorrelation between two numeric valuesdatasets of {x, y} points
MiniLineChart, MiniBarChart, MiniAreaChartsparklines inside KPI tilesnumber[] or [{ value, label? }]

There is no DonutChart, Histogram or PieChartCondensed.

2D charts​

  • data is a flat array of row objects, one per x-axis point: [{ month: "Jan", sales: 100, profit: 40 }, ...].
  • categoryKey names the x-axis field, and every row must contain it.
  • Every other numeric key is a series. Two series means two numeric keys per row, not two arrays. The legend shows the key name.
  • Always pass height (e.g. height={240}), otherwise the chart can collapse to zero height.
PropTypeApplies to
datarows (required)all
categoryKeystring (required)all
height, widthnumberall
customPalettestring[] (hex); see how it is appliedall
theme"ocean" \| "orchid" \| "emerald" \| "spectrum" \| "sunset" \| "vivid"all
grid, legend, showYAxisbooleanall
xAxisLabel, yAxisLabelnodeall
isAnimationActivebooleanall
variant"linear" \| "natural" \| "step"Line, Area
variant"grouped" \| "stacked"Bar
strokeWidthnumberLine
radius, maxBarWidthnumberBar
tickVariant"singleLine" \| "angled"condensed (non-scrollable) charts

How customPalette is applied​

The palette is not read in order. Every chart picks the colours for n series outward from the middle of the array:

SeriesColours used from a palette p of length L (mid = floor(L / 2))
1p[mid]
2p[mid - 1], p[mid + 1]
3 or moren consecutive colours centred on mid, wrapping around the ends

In practice:

  • 1 series: customPalette={["#3b82f6"]}.
  • 2 series: put a spacer in the middle: customPalette={[first, "#CBD5E1", second]}. A two-colour palette makes the second series black, because p[2] doesn't exist.
  • 3 series: three colours, in order.
  • 4 or more: pass exactly n colours and accept that the order rotates, or leave customPalette out and use theme ("ocean", "orchid", "emerald", "spectrum", "sunset", "vivid").

The same rule applies to PieChart, RadialChart and SingleStackedBar (one colour per slice). The mini charts take a single lineColor / barColor / areaColor instead.

Example Code​

function SalesTrend(props) {
const { title, rows } = props;
return (
<UI.Card variant="card">
<UI.CardHeader title={title} />
<UI.LineChart data={rows} categoryKey="month" variant="natural" grid legend showYAxis height={220} />
{/* 2 series → colours 1 and 3 of the palette are used (see "How customPalette is applied") */}
<UI.BarChart data={rows} categoryKey="month" variant="grouped" customPalette={["#6366F1", "#CBD5E1", "#14B8A6"]} legend height={220} />
<UI.AreaChart data={rows} categoryKey="month" variant="linear" legend height={220} />
<UI.ScrollableLineChart data={rows} categoryKey="month" grid height={220} />
</UI.Card>
);
}
module.exports.default = SalesTrend;

Example Data​

{
"title": "Sales vs profit",
"rows": [
{ "month": "Jan", "sales": 120, "profit": 40 },
{ "month": "Feb", "sales": 180, "profit": 65 },
{ "month": "Mar", "sales": 150, "profit": 50 },
{ "month": "Apr", "sales": 210, "profit": 90 }
]
}

HorizontalBarChart​

Same contract as BarChart. It uses showXAxis (not showYAxis), and variant is "grouped" | "stacked".

Example Code​

function TopAgents(props) {
const { rows } = props;
return <UI.HorizontalBarChart data={rows} categoryKey="agent" customPalette={["#10b981"]} grid showXAxis height={220} />;
}
module.exports.default = TopAgents;

Example Data​

{ "rows": [{ "agent": "Support bot", "calls": 412 }, { "agent": "Sales bot", "calls": 290 }, { "agent": "HR bot", "calls": 95 }] }

Part-to-whole (PieChart, RadialChart, SingleStackedBar)​

All three need both categoryKey (the slice name) and dataKey (the slice size). With {label, value} rows and no keys, nothing plots.

PropPieChartRadialChartSingleStackedBar
variant"pie" (default) | "donut""circular" (default) | "semicircle"—
format"percentage" | "number"same—
legend, legendVariant ("default" \| "stacked")✓✓✓
customPalette, theme✓✓✓
height, widthnumber or stringnumber or stringuse style
cornerRadius / paddingAngle✓ / ✓✓ / ——

Example Code​

function SpendBreakdown(props) {
const { data } = props;
return (
<UI.Card variant="card">
<UI.CardHeader title="Spend by category" />
<div style={{ display: "grid", gap: 24 }}>
<UI.PieChart data={data} categoryKey="category" dataKey="amount" variant="donut" format="percentage" legend />
<UI.RadialChart data={data} categoryKey="category" dataKey="amount" variant="semicircle" legend />
<UI.SingleStackedBar data={data} categoryKey="category" dataKey="amount" legend />
</div>
</UI.Card>
);
}
module.exports.default = SpendBreakdown;

Example Data​

{ "data": [{ "category": "Compute", "amount": 540 }, { "category": "Storage", "amount": 210 }, { "category": "Network", "amount": 90 }] }

RadarChart and ScatterChart​

UI.RadarChart — rows + categoryKey, where each other numeric key is a series. variant: "line" | "area", plus areaOpacity, strokeWidth, grid and legend.

UI.ScatterChart — data is a list of datasets: [{ name, data: [{ x, y, z? }] }]. Other props: xAxisDataKey / yAxisDataKey (default "x" / "y"), shape ("circle" | "square"), xAxisLabel, yAxisLabel, grid, legend and height.

Example Code​

function ModelComparison(props) {
const { skills, runs } = props;
return (
<UI.Card variant="card">
<UI.RadarChart data={skills} categoryKey="skill" variant="area" legend height={240} />
<UI.ScatterChart data={runs} xAxisLabel="Latency (ms)" yAxisLabel="Accuracy" grid legend height={240} />
</UI.Card>
);
}
module.exports.default = ModelComparison;

Example Data​

{
"skills": [
{ "skill": "Reasoning", "modelA": 82, "modelB": 74 },
{ "skill": "Coding", "modelA": 77, "modelB": 81 },
{ "skill": "Recall", "modelA": 69, "modelB": 72 }
],
"runs": [
{ "name": "Model A", "data": [{ "x": 120, "y": 0.82 }, { "x": 180, "y": 0.86 }] },
{ "name": "Model B", "data": [{ "x": 90, "y": 0.74 }, { "x": 140, "y": 0.79 }] }
]
}

Sparklines with no axes. data is number[] or [{ value, label? }]. Use size (a number or CSS size) for the height, and lineColor / barColor / areaColor for a single colour. MiniAreaChart also takes useGradient and opacity.

Example Code​

function KpiTiles(props) {
const { kpis } = props;
const tile = { flex: 1, minWidth: 140, padding: 12, border: "1px solid var(--border, #e5e7eb)", borderRadius: 10 };
return (
<div style={{ display: "flex", gap: 12, flexWrap: "wrap" }}>
{kpis.map((k) => (
<div key={k.label} style={tile}>
<div style={{ fontSize: 12, opacity: 0.7 }}>{k.label}</div>
<div style={{ fontSize: 20, fontWeight: 700 }}>{k.value}</div>
{k.kind === "bar" ? <UI.MiniBarChart data={k.trend} size={40} barColor="#6366F1" />
: k.kind === "area" ? <UI.MiniAreaChart data={k.trend} size={40} areaColor="#14B8A6" useGradient />
: <UI.MiniLineChart data={k.trend} size={40} lineColor="#EC4899" />}
</div>
))}
</div>
);
}
module.exports.default = KpiTiles;

Example Data​

{
"kpis": [
{ "label": "Revenue", "value": "$48k", "kind": "line", "trend": [12, 18, 15, 22, 28] },
{ "label": "Orders", "value": "1,204", "kind": "bar", "trend": [80, 95, 70, 120, 110] },
{ "label": "Users", "value": "9.8k", "kind": "area", "trend": [{ "value": 7 }, { "value": 8 }, { "value": 9.8 }] }
]
}