ComponentsIconsGuidesExamplesGetting started
ComponentsIconsGuidesExamplesGetting started
GitHub repository

Dashboard

Grid of resizable panes, dragged by the edges they share.

c2-dashboard is a CSS grid whose tracks the user can drag. Its children are c2-dash-card panes, each placed by col / row / col-span / row-span; a pane draws a handle on every edge it shares with a neighbour, and dragging one resizes the whole track, so the panes on either side of it stay aligned. columns and rows take either a track count (columns="3" is three equal columns) or an explicit list (columns="320px 1fr"). The first drag switches a track to pixels and the fr tracks around it give up the space in proportion to their weight, down to min-column-width / min-row-height and to whatever min-width / min-height the panes over those tracks ask for. Give the grid a height whenever its rows use fr — the row tracks divide the host’s height.

A pane draws no surface of its own: put a c2-card, or any markup, in its default slot. Filling header, actions or footer turns that row on; with header and actions both empty, the optional expand-width / expand-height / expand-full controls float over the top-right corner instead. Your own buttons go in actions (at the end of the header row) or in controls (inside the built-in group, right next to the expand buttons), and each built-in icon is a slot of its own — expand-full-icon, collapse-full-icon and the width and height pairs — whose fallback is the default drawing, so a pane can use the application’s icon set and keep the behaviour. An expanded pane covers its neighbours on an opaque --c2-dash-card__expanded--background (the theme’s surface colour by default); the pane itself stays transparent at rest. Whatever you slot into the pane fills it — the body is a column flex box and each slotted child is a flex: 1 item — so a chart or a code editor follows the row track without a height: 100% chain. The whole gutter between two panes drags: each handle is centred on its edge and as thick as --c2-dashboard--gap.

Set storage-key and the track sizes are written to localStorage at the end of each gesture and restored on the next load; layout-change reports them either way, and reset() puts the authored tracks back. A handle is a window splitter: it is in the tab order and the arrow keys move it, 10px a step and 1px with Shift.

For a grid that changes shape with the viewport, set layouts instead of remounting: an ordered list of entries, each with a media query and the columns, rows and layout (placements by card-id) to use while it matches. The first match wins, the grid switches in place as the viewport crosses a breakpoint, layout-change reports the switch, and each entry keeps its own stored sizes under <storage-key>@<media>.

grid.layouts = [
  { media: '(max-width: 1279px)', columns: 1, rows: 3, layout: { kpis: { row: 1 }, orders: { row: 2 }, activity: { row: 3 } } },
]

Installation

npm install @c2n/dashboard

Usage

Adding and removing panes

Panes can come and go at runtime. A c2-dash-card appended to a grid that is already on screen fades and scales in; to take one out with the same motion, either flip it to visible: false in the layout record — it fades, then hides — or call card.dismiss(), which plays the animation and removes the element once it is done (the promise resolves when it is gone, which is where a data-driven app drops the row). Cards present at load do not animate, --c2-dash-card__enter--animation-duration / --c2-dash-card__leave--animation-duration set the timing, and prefers-reduced-motion turns both off.

Placement stays yours. The grid never re-places cards on its own. A pane that is removed or hidden leaves its cells empty and its neighbours where they were; a pane added at runtime lands exactly where its col / row say, over whatever already occupies that cell. If the gap should close, or room should be made, the application decides how: set the remaining cards’ col / row / col-span / row-span, or hand the grid a layout record keyed by card-id. Both are applied in place, and the animations run alongside. The demo below does the simple version — it looks for the first free cell before adding.

Add paneClose a pane with its × — it fades out and leaves its cell empty; Add fills the first free cell.
Watchlist
Watchlist
Price
Price
Orders
Orders
Panes added and dismissed at runtime
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