UI components and display helpers
This page describes the shared controls and display surfaces that turn page data into usable application and dashboard views. It is the child guide for UI foundation, with focus on the component families, calendar surfaces, responsive signals, and data-display contracts that pages use together.
Component inventory
The component inventory follows a shadcn-style composition model. Small components provide one clear role, accept normal element props, and can be combined into larger page surfaces without taking ownership of the page’s business data.
Interaction primitives
Interaction primitives give pages consistent ways to start actions, enter values, choose options, and move between views. They cover buttons, button groups, text inputs, text areas, checkboxes, radio groups, switches, sliders, selects, command search, comboboxes, tabs, accordions, carousels, and pagination. Representative components include src/…/button.tsx, src/…/input.tsx, src/…/combobox.tsx, and src/…/tabs.tsx.
These primitives share a small set of variants and states. A page can therefore express an active, disabled, invalid, selected, or destructive state without creating a separate visual contract. Compound controls keep their parts related through the underlying root, trigger, content, item, and close roles.
References: src/…/button.tsx• L6-66 src/…/input.tsx• L4-15 src/…/combobox.tsx• L16-159 src/…/tabs.tsx• L9-90
Navigation and overlay surfaces
Navigation surfaces help users move through page context and available actions. Breadcrumbs show location, navigation menus and sidebars expose page structure, and menus or command palettes provide focused action lists. Dialogs, alert dialogs, drawers, sheets, popovers, hover cards, context menus, and tooltips temporarily place related content near the user’s focus.
These surfaces use shared trigger and content relationships. The page supplies the action or content, while the shared surface manages the focus, placement, open state, and close path expected by that interaction.
References: src/…/breadcrumb.tsx• L6-121 src/…/command.tsx• L20-117 src/…/dialog.tsx• L10-85 src/…/sidebar.tsx• L164-205 src/…/tooltip.tsx• L7-84
Content and identity surfaces
Content surfaces organize information after a page has chosen what to show. Cards group related content, items support compact rows with media and actions, and tables present records in columns. Badges, avatars, markers, attachments, and message or bubble parts add compact status, identity, annotation, file, and conversation displays.
These surfaces support several common content shapes without defining the business data behind them. An attachment can show file state, a message can align content by sender, and an item can combine media, text, and actions while the page remains responsible for the meaning of each value.
References: src/…/card.tsx• L4-102 src/…/item.tsx• L8-196 src/…/attachment.tsx• L26-204 src/…/avatar.tsx• L7-111 src/…/message.tsx• L4-91 src/…/bubble.tsx• L6-124
Form and guided-content surfaces
Form surfaces connect labels, help text, controls, and errors. The field family supports vertical, horizontal, and responsive arrangements, while input groups place text, actions, and add-ons around a control. The questionnaire family adds a step-based choice flow with progress, navigation, skip, submit, and error states.
The page owns the form values and validation result. The shared surfaces only make those values and results clear to the user, which keeps form behavior separate from form presentation.
References: src/…/field.tsx• L10-85 src/…/field.tsx• L88-223 src/…/input-group.tsx• L11-156 src/…/questionnaire.tsx• L10-189 src/…/questionnaire.tsx• L192-324
Feedback and state surfaces
State surfaces make the result of an action visible. Alerts and empty states explain problems or missing data, while progress bars, spinners, skeletons, and toast output show work in progress or completion. Attachment states and message scrollers extend the same idea to file work and long conversation views.
These components let a feature explain its state with a shared structure instead of changing the meaning of the page layout. The page still decides which state applies and what message the user needs.
References: src/…/alert.tsx• L5-75 src/…/empty.tsx• L4-103 src/…/progress.tsx• L8-31 src/…/attachment.tsx• L8-45 src/…/message-scroller.tsx• L15-131 src/…/sonner.tsx• L7-49
Date and calendar surfaces
Date controls support both a single calendar view and a higher-level date-range flow. They use one calendar presentation so date selection in a filter, form, or dashboard view has the same interaction model.
Calendar control
The shared Calendar component presents a react-day-picker calendar with month navigation, optional outside days, locale-aware month labels, week numbers, disabled days, and selected-range styling. It also exposes the day button as a reusable part, which lets callers use the same focus and selection treatment when they build a larger date control. src/…/calendar.tsx provides the common calendar surface.
The calendar accepts the day-picker modes and values supplied by its caller. This keeps the basic control useful for a single date, a range, or another supported selection model without making the calendar responsible for the surrounding form or filter state.
References: src/…/calendar.tsx• L15-45 src/…/calendar.tsx• L46-179 src/…/calendar.tsx• L183-222
Date-range selection
DateRangePicker turns the calendar into a compact filter control. It shows the current range in a button, opens the calendar in a popover, and displays two months so a user can select a start and end date in one surface. src/…/date-range-picker.tsx• L17-59 provides this flow.
The picker supports two ownership modes. In controlled mode, the page supplies the range and updates it from onChange; in local mode, the picker keeps the range itself and starts with the last 30 days. This lets simple pages use the helper directly while filter-heavy pages keep the selected range in their own state.
The selection flow is summarized below.
flowchart LR
A[Page or local state] --> B[Date range button]
B --> C[Popover]
C --> D[Two-month calendar]
D --> E[Selected range]
E --> F[onChange]
F --> A
References: src/…/date-range-picker.tsx• L12-24 src/…/date-range-picker.tsx• L25-40 src/…/date-range-picker.tsx• L42-59 src/…/calendar.tsx• L112-135
Event calendar views
EventCalendarViews is the shared event presentation layer for FullCalendar. It keeps event colors, focus states, day headers, dense cells, resize affordances, overflow links, and empty list states consistent while allowing a page to choose its event data and calendar options.
Event view modes
The helper covers four broad view modes: day grids, multi-month grids, time grids, and event lists. Each mode changes how users scan time, while the shared rules preserve the same meaning for selected events, today markers, background events, and events that do not fit in a cell. src/…/event-calendar-views.tsx• L399-492 maps these view-specific choices.
The event display adapts to narrow cells and short events. It supports selected and interactive events with focus treatment and start or end resize handles. Pages supply the calendar options and event behavior; this helper supplies the shared visual language around them.
References: src/…/event-calendar-views.tsx• L73-126 src/…/event-calendar-views.tsx• L128-205 src/…/event-calendar-views.tsx• L254-397 src/…/event-calendar-views.tsx• L399-497
Data-display capabilities
Data-display helpers translate records into views that users can scan, compare, and act on. Tables handle structured rows, charts summarize values, and small value helpers keep identity and number formatting consistent across those views.
Code blocks
The src/…/code-block.tsx component presents code as a readable, focusable surface with optional titles, actions, copying, wrapping, line numbers, and line-level states. It gives streamed output, examples, and diffs one shared display shape while leaving the code content and language to the page.
Code highlighting is separate from the layout surface. useHighlightedCode loads a supported language on demand, keeps complete lines highlighted as text grows, and highlights the active last line again while it is still being written. If the language is not supported or loading fails, the hook returns plain text so code remains visible. src/…/highlighter.tsx defines the supported language names and aliases.
References: src/…/code-block.tsx• L27-43 src/…/code-block.tsx• L87-137 src/…/code-block.tsx• L139-225 src/…/use-highlighted-code.ts• L5-30 src/…/use-highlighted-code.ts• L32-73 src/…/highlighter.tsx• L6-33 src/…/highlighter.tsx• L61-107
Trace displays
The src/…/trace.tsx component presents a sequence of work or reasoning steps as compact lines. Each line can show an icon, title, description, and status, so a parent view can distinguish pending, running, and error work without changing its overall layout.
Trace groups can contain expandable detail. The trigger keeps the collapsed or expanded state visible, while the content area provides a nested reading path for related events or output. This makes traces useful for progress views where users need a short summary first and more detail only when they ask for it.
References: src/…/trace.tsx• L11-42 src/…/trace.tsx• L44-82 src/…/trace.tsx• L84-150
Table behavior
The shared data-table feature registry defines the row and column capabilities expected by dashboard tables. It registers column and global filtering, faceting, sizing, visibility, pagination, selection, and sorting together with common text, list, alphanumeric, and date-time rules. src/…/data-table-features.ts• L24-56 is the cross-table contract.
The registry keeps a table’s data operations aligned with its column definitions and reusable table controls. The presentational Table surface adds a consistent responsive scroll boundary and row, header, cell, footer, and caption structure. src/…/table.tsx• L6-115 provides that display layer.
| Capability | User-facing result |
|---|---|
| Filtering and faceting | Narrow records by text, value, or grouped values. |
| Sorting | Order records by text, alphanumeric value, or date and time. |
| Sizing and visibility | Adjust which columns appear and how much space they use. |
| Selection | Mark rows for a follow-up action. |
| Pagination | Move through a large result set in pages. |
References: src/…/data-table-features.ts• L1-22 src/…/data-table-features.ts• L24-56 src/…/table.tsx• L6-115
Chart presentation
The chart surface gives Recharts-based views a shared container and a page-owned chart description. The description maps data keys to labels, icons, and either one color or light and dark theme colors. Shared tooltip and legend content then use that description to explain each series in the same way. src/…/chart.tsx• L14-115 and src/…/chart.tsx• L116-372 define this relationship.
Charts remain responsive through their container, while the shared tooltip and legend hide empty payloads and format visible values for scanning. The page still owns the data series and chart type; the helper owns the display contract around those series.
References: src/…/chart.tsx• L14-80 src/…/chart.tsx• L83-115 src/…/chart.tsx• L116-269 src/…/chart.tsx• L272-372
Identity and value helpers
Small helpers cover values that recur across data views. SimpleIcon turns a simple-icons icon into an accessible SVG, using the icon title as its accessible label and path while accepting normal SVG properties and style overrides. getInitials supplies a safe avatar fallback and formatCurrency applies locale and currency rules to numeric values. src/…/simple-icon.tsx• L8-29 and src/…/utils.ts• L1-35 provide these helpers.
These helpers keep the meaning of a value stable when it moves between a card, table, chart legend, mail row, or dashboard summary. They complement the Avatar, Badge, and Progress surfaces rather than replacing the page-specific data model.
References: src/…/simple-icon.tsx• L8-29 src/…/utils.ts• L1-35 src/…/avatar.tsx• L7-111 src/…/badge.tsx• L6-48
Responsive presentation
Responsive presentation uses shared browser-width signals so a page and its UI surfaces change at compatible boundaries. The hooks are small client-side signals that support view choices; CSS and component layout rules still control the final arrangement.
Breakpoint hooks
useIsMobile reports whether the viewport is below 768 pixels, and useIsLg reports whether it is at least 1024 pixels. Each hook listens for viewport changes and updates its result, so a page can switch between a compact view and a larger view while the user resizes the browser. src/…/use-mobile.ts• L3-18 and src/…/use-lg.ts• L3-18 define these shared boundaries.
The hooks are useful when the page must choose a different component or interaction model, such as changing an inline navigation surface to a temporary mobile surface. They should use the same breakpoint meaning as the components around them so content does not move at one width while its controls move at another.
References: src/…/use-mobile.ts• L3-18 src/…/use-lg.ts• L3-18 src/…/field.tsx• L54-69 src/…/sidebar.tsx• L164-205
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the root, trigger, content, item, and close relationships intact when changing a compound control. A page may rely on the underlying accessible interaction contract rather than on the wrapper’s visual classes.
- Keep the
DateRangevalue shape and controlled callback behavior aligned betweenDateRangePicker, its calendar, and every caller that stores the selected range. - Keep FullCalendar view names, event option types, and the required
popoverCloseContentcontract aligned when adding or changing event views. - Keep chart configuration keys aligned with the data keys used by series, tooltips, and legends. Keep light and dark color values aligned with the theme tokens.
- Keep the shared data-table feature registry aligned with table instances and the column behavior they expose. A registry change can alter row models without changing the page markup.
- Keep code language names aligned with the supported language list and aliases. Unsupported names must still have a clear plain-text result.
- Keep code block line content compatible with highlighting output when adding line numbers, wrapping, or diff states. These options affect how users read and copy the same code.
- Keep trace status values and collapsible trigger/content relationships aligned with the progress data that feeds a trace.
- Treat the 768-pixel mobile boundary and 1024-pixel large-screen boundary as shared contracts. Check page choices and component layout changes together.
- Preserve accessible names for brand icons, loading indicators, pagination controls, carousel controls, and empty or error states when changing their visible content.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
A controlled DateRangePicker caller does not replace its supplied value after onChange | The button and calendar keep showing the old range | Update the state passed to value from the callback result |
A chart tooltip or legend is rendered outside ChartContainer | The shared chart helper cannot read its configuration and throws at runtime | Keep chart display parts inside the chart container with a matching config |
| A chart series key has no matching chart configuration entry | Labels or theme colors are missing from the tooltip or legend | Use the same keys in the series and ChartConfig |
| A table uses filtering, sorting, pagination, or selection without the matching registered feature | The control may render without changing the row model or the table type contract | Use the shared dataTableFeatures registry for dashboard table instances |
| A view is added to FullCalendar without the required popover close content | The event view contract is incomplete and cannot provide its close control | Supply popoverCloseContent and merge the view with the shared options |
| A page and a component use different meanings for a responsive breakpoint | Controls can switch to a mobile or desktop form at the wrong width | Reuse the shared hook boundaries and related responsive component rules |
| A code block requests an unknown language or its highlighter fails to load | The code has no color tokens and appears as plain text | Use a supported language or alias when highlighting is needed, and keep the plain-text fallback readable |
| A streaming code value changes before the prior text or switches language without a new highlight context | Previously produced lines can no longer match the current grammar state | Reset highlighting when the value is not an extension of the prior text or when the language changes |
| A trace trigger is separated from its collapsible content or receives an invalid status | Detail may not open correctly or status styling may not match the work state | Keep each trigger/content pair together and use running, error, or pending status values |
| A compound control loses its root, trigger, content, or close relationship | Focus, keyboard input, selection, or close behavior can stop working | Preserve the wrapper’s underlying primitive structure |
Key files
| File | Why to read it |
|---|---|
| src/…/button.tsx | Shows the shared action variants, sizes, states, and element composition pattern. |
| src/…/field.tsx | Shows how labels, descriptions, controls, and errors form a reusable input unit. |
| src/…/card.tsx | Shows the main content-surface composition pattern. |
| src/…/calendar.tsx | Defines the shared calendar selection and date presentation surface. |
| src/…/date-range-picker.tsx | Shows the complete date-range button, popover, and calendar flow. |
| src/…/event-calendar-views.tsx | Defines shared event presentation across grid, time, multi-month, and list views. |
| src/…/data-table-features.ts | Defines the common table row and column capabilities. |
| src/…/table.tsx | Defines the shared responsive table presentation surface. |
| src/…/chart.tsx | Defines chart configuration, responsive containment, tooltips, and legends. |
| src/…/code-block.tsx | Defines the shared code surface, copy action, line display, and code states. |
| src/…/trace.tsx | Defines compact progress traces and expandable detail. |
| src/…/use-highlighted-code.ts | Keeps streamed code highlighting current while allowing plain-text fallback. |
| src/…/highlighter.tsx | Defines the supported code languages, aliases, themes, and token output. |
| src/…/simple-icon.tsx | Provides the shared accessible brand-icon wrapper. |
| src/…/utils.ts | Provides initials and currency display helpers used by data views. |
| src/…/use-mobile.ts | Defines the shared mobile viewport signal. |
| src/…/use-lg.ts | Defines the shared large-screen viewport signal. |
| docs/ui-foundation.md | Explains how these components and helpers fit into the wider UI foundation. |