ComponentsIconsGuidesExamplesGetting started
ComponentsIconsGuidesExamplesGetting started
GitHub repository

Area chart

A line chart with the region under each line filled — every line-chart attribute, plus a fill opacity.

c2-area-chart

A line chart with the region under each line filled — an area chart is a line chart plus a fill, so it extends c2-line-chart and every one of its attributes (curve, points, zoom, the axis bounds) means the same thing here.

<c2-area-chart x-type="time" x-field="t" fill-opacity="0.2" data="[]">
  <c2-chart-series field="sessions" label="Sessions"></c2-chart-series>
</c2-area-chart>

Attributes

NameTypeDefaultDescription
fill-opacitynumber | undefined—Opacity of the fill under each line. Falls back to --c2-chart__area--opacity.
curve'linear' | 'smooth' | 'step'linearInterpolation between points.
points'auto' | 'always' | 'none'autoWhen point markers are drawn. auto lets uPlot show them once points are far enough apart.
grid'both' | 'x' | 'y' | 'none'yWhich grid lines are drawn. A string rather than a boolean because a boolean attribute reads as true whenever it is present — grid="false" in markup would turn the grid on, and there would be no way to turn it off from HTML at all. y (the default) draws the horizontal lines, matching axes' shape.
axes'both' | 'x' | 'y' | 'none'bothWhich axes are drawn.
y-minnumber | undefined—Lower bound of the y scale. Auto-ranged when unset.
y-maxnumber | undefined—Upper bound of the y scale. Auto-ranged when unset.
zoombooleanfalseLets the user drag horizontally to zoom the x scale.
cursor'x' | 'none'xThe cursor crosshair.
dataChartInput | undefined—The data to plot. Row objects, a bare number[], columnar [xs, ys…], or an already-normalised frame. Compared by identity: replace the array, or bump revision after mutating it in place.
revisionnumber0Bump after mutating data in place. The cheap escape hatch for a large buffer you own.
seriesChartSeriesConfig[] | undefined—Series definitions, as an alternative to c2-chart-series children. Children win when both are set.
x-fieldstring—Row field holding the x value; may be a dotted path. Defaults to the row index.
label-fieldstring—Row field holding the category label, for charts that name their slices.
x-type'time' | 'linear' | 'category'linearHow x values are interpreted, which decides the axis and the tooltip format.
legend'none' | 'top' | 'bottom' | 'start' | 'end'bottomWhere the legend sits, or none to hide it. Shown by default: a chart with more than one series is unreadable without one, and a single-series chart simply renders a one-entry legend.
tooltip'none' | 'item' | 'axis'axisWhether the tooltip follows the whole x position or only the hovered datum.
animation'none' | 'auto'autoWhether the chart animates its initial draw. ECharts uses its native shape animation and uPlot uses a lightweight plot reveal; subsequent data updates stay immediate so a live source does not animate every tick. Named animation rather than animate because HTMLElement.animate() is a method every element already has, and shadowing it breaks the Web Animations API on the host.
localestring | undefined—BCP 47 locale for the axis and tooltip formatting. Defaults to the browser locale.
loadingbooleanfalseShows the loading state instead of the plot.
errorstring—Shows an error message instead of the plot.
empty-messagestringNo dataReplaces the built-in "no data" text.
max-pointsnumber0Caps how many points a streaming chart keeps; older points fall off the front. 0 keeps everything.
lazy-renderbooleanfalseDefers loading the engine until the host first scrolls into view.

Slots

NameDescription
defaultThe series definitions: c2-chart-series elements. They render nothing themselves.
legendReplaces the built-in legend. The built-in one is still what legend positions.
tooltipReplaces the built-in tooltip body. The hovered point is available through the renderTooltip property when a function is easier than markup.
actionsControls pinned to the top-right of the plot area, for a range picker or an export button.
emptyReplaces the built-in "no data" message.
loadingReplaces the built-in message shown while loading is set.
errorReplaces the built-in message shown when error is set.

Events

NameTypeDescription
tooltip-changeCustomEvent<ChartTooltipContext | null>Fired with the complete tooltip model as the pointer moves, and with null when it leaves. Used by c2-chart-tooltip.
series-toggleCustomEvent<ChartSeriesToggleEventDetail>Fired when a legend entry is toggled. Does not bubble.
legend-changeCustomEvent<ChartLegendChangeEventDetail>Fired when legend entries or visibility change. Used by c2-chart-legend.
range-changeCustomEvent<ChartRangeEventDetail>Fired after the user zooms or brushes. detail.min and detail.max are the new x bounds. Does not bubble.
chart-readyCustomEvent<{ engine: string }>Fired after the engine has loaded and drawn for the first time. The host also gains data-chart-ready, which is what a test should wait on.
chart-errorCustomEvent<{ error: unknown }>Fired when the engine fails to load or to draw. detail.error is the underlying failure.
point-hoverCustomEvent<ChartPointEventDetail | null>Fired as the pointer moves between data points, and with a null detail when it leaves the plot. Does not bubble.
point-clickCustomEvent<ChartPointEventDetail>Fired when a datum is clicked. Does not bubble: several components fire point events, so a listener belongs on the element itself.

CSS parts

Shadow DOM styling hooks used with ::part(name). Prefer CSS custom properties when they cover the change.

NameDescription
frameThe outer flex column holding the legend and the plot area.
plot-areaThe positioned box the engine draws into.
plotThe engine's container element. Carries no Lit bindings, so the canvas survives every update.
overlayThe non-interactive layer above the canvas that holds the tooltip and the actions.
tooltipComponent-owned bubble containing the tooltip slot and its generated fallback content.
actionsThe container for the actions slot.
stateShared message layer containing the empty, loading, or error slot and its fallback state.
legendComponent-owned container wrapping the legend slot and generated legend fallback.
legend-itemOne legend entry, a toggle button.
legend-markerThe colour swatch inside a legend entry.

CSS custom properties

Grouped by semantic target and state from --c2-component__target__state--property. Click a group to collapse it; click a name to copy it.

NameTypeDefaultDescription
c2-chart
--c2-chart--widthlength100%Width of the host. The plot is absolutely positioned and has no intrinsic width, so a chart used as a flex item would otherwise collapse to its legend.
--c2-chart--heightpixel320pxHeight of the host. A canvas has no intrinsic size, so this is what gives the chart a box.
--c2-chart--backgroundcolor#ffffffBackground of the chart surface.
--c2-chart--colorcolor#18181bPrimary text colour.
--c2-chart--font-familyfont-familyinheritFont family used for the chart chrome and the labels the engine draws.
--c2-chart--font-sizefont-size12pxBase font size.
--c2-chart--paddingpadding12pxPadding around the whole chart.
--c2-chart--border-topborder1px solid #e4e4e7Top border.
--c2-chart--border-rightborder1px solid #e4e4e7Right border.
--c2-chart--border-bottomborder1px solid #e4e4e7Bottom border.
--c2-chart--border-leftborder1px solid #e4e4e7Left border.
--c2-chart--border-top-left-radiusborder-radius8pxTop-left corner radius.
--c2-chart--border-top-right-radiusborder-radius8pxTop-right corner radius.
--c2-chart--border-bottom-left-radiusborder-radius8pxBottom-left corner radius.
--c2-chart--border-bottom-right-radiusborder-radius8pxBottom-right corner radius.
c2-chart > axis-line
--c2-chart__axis-line--colorcolor#e4e4e7Colour of the axis rules uPlot draws at the plot edges.
c2-chart > series-1
--c2-chart__series-1--colorcolor#0265dcColour of the first series.
c2-chart > series-2
--c2-chart__series-2--colorcolor#ea580cColour of the second series.
c2-chart > series-3
--c2-chart__series-3--colorcolor#0f766eColour of the third series.
c2-chart > series-4
--c2-chart__series-4--colorcolor#db2777Colour of the fourth series.
c2-chart > series-5
--c2-chart__series-5--colorcolor#a16207Colour of the fifth series.
c2-chart > series-6
--c2-chart__series-6--colorcolor#7c3aedColour of the sixth series.
c2-chart > series-7
--c2-chart__series-7--colorcolor#0891b2Colour of the seventh series.
c2-chart > series-8
--c2-chart__series-8--colorcolor#52525bColour of the eighth series. Series beyond the eighth reuse the palette from the start.
c2-chart > line
--c2-chart__line--widthpixel2pxStroke width of a line series.
c2-chart > point
--c2-chart__point--radiuspixel2.5pxRadius of a data point marker.
c2-chart > area
--c2-chart__area--opacityopacity0.15Opacity of the fill under an area series.
c2-chart > bar
--c2-chart__bar--border-radiusnumber0Roundedness of a bar's value end, from 0 (square) to 0.5 (fully rounded).
c2-chart > axis
--c2-chart__axis--colorcolor#71717aColour of the axis lines and tick labels.
--c2-chart__axis--font-sizefont-size12pxFont size of the tick labels.
c2-chart > grid
--c2-chart__grid--colorcolor#e4e4e7Colour of the grid lines.
--c2-chart__grid--widthpixel1pxWidth of the grid lines.
c2-chart > crosshair
--c2-chart__crosshair--colorcolor#a1a1aaColour of the cursor crosshair.
--c2-chart__crosshair--widthpixel1pxWidth of the cursor crosshair.
c2-chart > surface
--c2-chart__surface--colorcolor#ffffffSurface colour handed to the engine, for marker borders and label backdrops.
c2-chart > muted
--c2-chart__muted--colorcolor#71717aSecondary text colour.
c2-chart > positive
--c2-chart__positive--colorcolor#16a34aColour for a rising value, used by the candlestick and gauge charts.
c2-chart > negative
--c2-chart__negative--colorcolor#dc2626Colour for a falling value, used by the candlestick and gauge charts.
c2-chart > legend
--c2-chart__legend--gappixel12pxGap between legend entries.
--c2-chart__legend--paddingpadding8px 0 0Padding around the legend.
--c2-chart__legend--colorcolor#71717aLegend text colour.
--c2-chart__legend--font-sizefont-size12pxLegend font size.
c2-chart > legend > disabled
--c2-chart__legend__disabled--opacityopacity0.38Opacity of a legend entry whose series is hidden.
c2-chart > legend-marker
--c2-chart__legend-marker--sizepixel10pxSize of the legend colour swatch.
--c2-chart__legend-marker--border-radiusborder-radius999pxCorner radius of the legend colour swatch.
c2-chart > tooltip
--c2-chart__tooltip--background-colorcolor#18181bTooltip background.
--c2-chart__tooltip--colorcolor#fafafaTooltip text colour.
--c2-chart__tooltip--font-sizefont-size12pxTooltip font size.
--c2-chart__tooltip--paddingpadding8px 10pxTooltip padding.
--c2-chart__tooltip--border-radiusborder-radius6pxTooltip corner radius.
--c2-chart__tooltip--box-shadowbox-shadow0 8px 24px rgba(24, 24, 27, 0.08)Tooltip shadow.
--c2-chart__tooltip--gappixel6pxGap between tooltip rows.
c2-chart > state
--c2-chart__state--colorcolor#71717aColour of the empty, loading and error text.
--c2-chart__state--font-sizefont-size14pxFont size of the empty, loading and error text.

c2-chart-series

One series of a chart, declared as a light-DOM child. The element renders nothing: it is a definition the chart reads, the same way c2-table reads its c2-table-column children. Everything it exposes as an attribute can also be set as a property, and format is property-only.

<c2-line-chart x-field="month" data='[{ "month": 1, "revenue": 120, "cost": 80 }]'>
  <c2-chart-series field="revenue" label="Revenue"></c2-chart-series>
  <c2-chart-series field="cost" label="Cost" color="#ea580c"></c2-chart-series>
</c2-line-chart>

Attributes

NameTypeDefaultDescription
fieldstring—Key of the value in the row object; may be a dotted path such as stats.cpu.
labelstring | undefined—Legend and tooltip label. Falls back to the field name.
colorstring | undefined—Explicit colour. Falls back to this series' slot in the chart's palette.
line-widthnumber | undefined—Stroke width in pixels. Falls back to --c2-chart__line--width.
axis'left' | 'right'leftWhich y axis the series is drawn against.
span-gapsbooleanfalseJoins across gaps instead of breaking the line.
hiddenbooleanfalseLeaves the series out of the chart without removing the definition.

c2-chart-legend

A legend linked to a chart by id. Place it anywhere in the document to control the legend's layout independently from the chart.

Attributes

NameTypeDefaultDescription
forstring—Id of the chart this element presents.

Slots

NameDescription
(default)Replaces the generated legend. Use renderLegend or renderLegendItem for data-driven custom content.

CSS parts

Shadow DOM styling hooks used with ::part(name). Prefer CSS custom properties when they cover the change.

NameDescription
itemOne interactive legend entry.
markerThe colour swatch inside an entry.

CSS custom properties

Grouped by semantic target and state from --c2-component__target__state--property. Click a group to collapse it; click a name to copy it.

NameTypeDefaultDescription
c2-chart
c2-chart > legend
--c2-chart__legend--gappixel12pxGap between legend entries.
--c2-chart__legend--paddingpadding0Padding around the legend.
--c2-chart__legend--colorcolor#71717aLegend text colour.
--c2-chart__legend--font-sizefont-size12pxLegend font size.
c2-chart > legend > disabled
--c2-chart__legend__disabled--opacityopacity0.38Opacity of a disabled entry.
c2-chart > legend-marker
--c2-chart__legend-marker--sizepixel10pxSize of the colour swatch.
--c2-chart__legend-marker--border-radiusborder-radius999pxRadius of the colour swatch.

c2-chart-tooltip

A tooltip linked to a chart by id. It can float beside the hovered point or render inline wherever it is placed in the document.

Attributes

NameTypeDefaultDescription
position'floating' | 'inline'floatingWhether the tooltip follows the hovered point or occupies its authored HTML position.
placement'top' | 'bottom' | 'start' | 'end'topPreferred side of the hovered point when position="floating". Flips at viewport edges.
forstring—Id of the chart this element presents.

Slots

NameDescription
(default)Replaces the generated tooltip body. Use renderTooltip for data-driven custom content.

CSS parts

Shadow DOM styling hooks used with ::part(name). Prefer CSS custom properties when they cover the change.

NameDescription
bubbleThe tooltip surface.

CSS custom properties

Grouped by semantic target and state from --c2-component__target__state--property. Click a group to collapse it; click a name to copy it.

NameTypeDefaultDescription
c2-chart
c2-chart > tooltip
--c2-chart__tooltip--background-colorcolor#18181bTooltip background.
--c2-chart__tooltip--colorcolor#fafafaTooltip text colour.
--c2-chart__tooltip--font-sizefont-size12pxTooltip font size.
--c2-chart__tooltip--paddingpadding8px 10pxTooltip padding.
--c2-chart__tooltip--border-radiusborder-radius6pxTooltip corner radius.
--c2-chart__tooltip--box-shadowbox-shadow0 8px 24px rgba(24, 24, 27, 0.08)Tooltip shadow.
--c2-chart__tooltip--gappixel6pxGap between tooltip rows.
c2-chart > legend-marker
--c2-chart__legend-marker--sizepixel10pxSize of the colour swatch in a tooltip row.
--c2-chart__legend-marker--border-radiusborder-radius999pxCorner radius of a tooltip row's colour swatch.
escAccordionConnected, animated panels with shared borders and single or multiple expansion.LayoutArea chartA line chart with the region under each line filled — every line-chart attribute, plus a fill opacity.ChartAttachmentFile and image attachments with metadata, upload progress, failure states, and actions.Data displayAutocompleteSearchable combobox for local or remote items with customizable list rows.InputsAvatarImage, initials or icon for a person, with status dot and badge.Data displayBadgeTinted pill for status text, counts and dots, optionally pinned to a corner of another element.Data displayBar chartBars over categories or time buckets, with several series drawn side by side within each band.ChartBorder BeamA decorative beam that travels around the border of any positioned container.LayoutBreadcrumbNavigation trail of link buttons with separators, a current page and optional collapsing.NavigationButtonThemeable button with slots for text, prefix, suffix and running icons.ButtonsButton GroupJoined actions and polished segmented controls with single or multiple selection.ButtonsCandlestick chartAn ECharts OHLC chart for market sessions and other open-close ranges, with semantic positive and negative colours.ChartCardGroups related content and actions on a single bordered surface.LayoutCascaderSelect a value from related, multi-level data in one floating panel.InputsChat InputAuto-growing message composer with keyboard submission, toolbar actions and native form support.ChatChat MessageFlexible message row for conversations, assistant answers and activity updates.ChatCheckboxNative checkbox behaviour in a quiet, themeable box with an opt-in hover layer.InputsCode EditorEditable, syntax-highlighted source field on CodeMirror 6, themed entirely through CSS variables.InputsCode ViewerSyntax-highlighted code with line numbers, copy button and dark mode, powered by shiki.Data displayColor AreaTwo-dimensional area for picking saturation and value of a colour.InputsColor SelectColour swatch that opens a full picker built from area and slider.InputsColor SliderHorizontal slider for choosing a hue from 0 to 360.InputsCopy ButtonButton that copies text to the clipboard — the element it sits in, another element by id, or a literal string.ButtonsDashboardGrid of resizable panes, dragged by the edges they share.LayoutDate InputForm-associated single-date input with native picker, constraints, helper text and error states.InputsDate SelectorAccessible one- or two-month calendar for choosing a date range.InputsDetailsCollapsible disclosure built on native details and summary.LayoutGauge chartA focused radial KPI gauge drawn by ECharts, with a configurable scale, progress arc and pointer.ChartHeaderArranges brand, navigation, actions and a mobile trigger in a reusable site shell.LayoutIcon ButtonRound, hoverable button wrapping a slotted SVG icon.ButtonsKbdKeyboard key label for shortcuts and command hints, with the semantics of the native kbd element.Data displayLabelCaption that names and activates the control referenced by its for attribute, with a required marker.InputsLine chartA line chart over a time or numeric x axis, drawn on canvas by uPlot, with series declared as children.ChartLink ButtonText-styled control for link and navigation actions, rendered as a real anchor or a button.NavigationListVertical list container with single or multiple selection.Data displayList ItemSelectable row with icon slots, used on its own or as the option of list and select.Data displayMenuCommands, links, checkboxes and submenus in a popover anchored to a trigger.NavigationModalDialog built on the native dialog element: focus trap, backdrop, Escape, title, body and footer.FeedbackNavigation MenuSite navigation bar whose triggers open panels of links below the header.NavigationNumber InputForm-associated numeric input with native validation, step controls, adornments and helper states.InputsOverlayAnchored popup built on the browser Popover API, positioned with floating-ui.FeedbackPaginationPage navigation in three layouts: numbered pages, a simple page status, or a table-footer row with rows-per-page.NavigationPie chartA pie or donut chart drawn by ECharts, where one row is one slice and label-field names it.ChartProgressLinear progress bar, indeterminate or filling to a value, with an optional label and count.FeedbackQR CodeGenerate accessible, themeable QR codes locally as crisp SVG graphics.Data displayQuestionnaireA multi-step single- and multiple-choice flow with validation, shortcuts and form submission.InputsRadar chartCompare several profiles across the same set of normalized indicators.ChartRadioRadio options built on native inputs, grouped into one value with keyboard navigation.InputsRateAccessible star rating input with hover preview, keyboard control and optional half values.InputsReorder ListReorder a vertical queue with pointer or keyboard input while the application owns persistence.Data displayScatter chartAn ECharts scatter plot for finding relationships, clusters and outliers across two numeric measures.ChartSelectDropdown that pairs a themeable trigger with an anchored list of c2-list-item options.InputsSeperatorHorizontal or vertical rule with an optional label, for dividing content and toolbars.LayoutSheetDialog pinned to an edge of the screen, for content that complements the page rather than interrupting it.FeedbackSide NavResponsive navigation drawer beside the page: pushes the content on large screens, slides over it with a backdrop on small ones.NavigationSkeletonPlaceholder block standing in for content that has not arrived, in three shapes and three animations.FeedbackSliderRange input with a themeable track, thumb, step ticks and value bubble.InputsSparklineA chromeless trend line sized for a table cell, a list row or the trend slot of a c2-stat.ChartSpinnerCircular progress indicator, indeterminate or showing a value, with optional text.FeedbackStatDisplays a KPI with an optional icon, trend and supporting description.Data displayStatus PanelCommunicate empty states, operation outcomes and recoverable errors with clear next steps.FeedbackStepsA vertical trace of a task as it runs: statuses, durations, and stages that open while they work and close when they are done.Data displaySwitchOn/off toggle on a native switch input, with label, description and thumb icons.InputsTableVirtualized data grid with declarative columns, sorting, selection, pinning and resizing.Data displayTabsTab strip that shows one content panel at a time.NavigationText FieldSingle-line input with icon slots, clear button, helper and error text, and a character counter.InputsTextareaMultiline text input with resizing, helper and error text, and a character counter.InputsTheme SelectColour-theme switcher: click to step to the next mode, hover for the full menu.InputsToastNotification cards and a manager for stacked, queued notifications with independent lifetimes.FeedbackTooltipContextual hint shown when its target is hovered or focused, rendered in the top layer.FeedbackTreeHierarchical tree view with expansion, selection, checkboxes and lazy loading.Data displayUploadDrag-and-drop file selection with validation, upload progress, retry, cancellation, and attachment results.InputsVirtual ListWindowed list with built-in search, sorting, selection and an async data source.Data displayFeather Icons287 open-source Feather icons, one web component each.IconsMat Icon2,234 Material Icons ligatures rendered through a single element.IconsPhosphor Icons1,512 flexible icons in six weights, one web component each.IconsThemingTheme every c2n component from a handful of design tokens with @c2n/theme, or reach for any component variable directly.GuideFrameworksUse the components from React, Vue, Angular, Svelte, Lit or plain HTML — typed events, generated template types, and the one piece of configuration each framework needs.GuideUsing c2n in an applicationThe workflow behind every c2n app: load the theme once, use c2-* tags directly, and turn every repeated pattern into a small variant or composed component.GuideAI toolsGive Claude Code, Codex or Google Antigravity the c2n skill, live component APIs, examples and application conventions.Guide