---
name: lumo-widgets
description: Build, update, or review Lumo widgets and their Studio or device previews. Use for layout and typography, shared UI and tokens, data visualization, widget interactions, motion, and public React data contracts.
---

# Lumo widgets

Use the [interactive design system](/design-system) to check the intended behavior. In the Lumo workspace, the implementation is the source of truth. Keep the examples on that page aligned with any intentional changes to shared rules.

## Review an existing widget

- Start with the task the widget should help someone complete. Identify the essential reading, its units and date or period, relevant statuses, and the next useful action. Check which details are missing and move secondary information into an in-card detail view when that improves readability.
- For an adapted widget, rebuild the visual hierarchy with Lumo components and tokens. Write original labels and sample data. Keep the widget ID and its integration entry points when they still serve the same purpose.
- Keep the card surface static when switching between companion views, and reserve action buttons for specific tasks. Follow the dot and swipe rule under Fit and overflow.
- Review the public data contract and example alongside the visual design. Check empty and unavailable data, then verify that the layout and interactions work at standalone and Studio sizes before updating the widget’s version and publication metadata.

## Card and typography

- Compose with `WidgetCard`, `WidgetHeader`, and controls from `@lumo/ui`. Put the icon on the title row, with the description below. The disc and glyph use `--widget-header-icon-size` (1.75rem) and `--widget-header-glyph-size` (1rem). Keep both dimensions fixed when the title wraps.
- Use Inter through `--font-body` for widget titles, descriptions, labels and units. Titles use `--widget-title-size` (16 px) and `--widget-title-weight` (600). Descriptions use `--widget-description-size` (13 px) and `--widget-description-weight` (400). These sizes assume the default root text size. Give the description the full available width after the icon, including the space below a title-row action. Let the full description wrap when it needs more room.
- Use Geist through `--font-display` with tabular digits for the main reading. Keep the unit beside the value and give essential labels and units at least `--text-xs` (12 px at the default root text size). Use the shared `rem` scale and check that labels and controls remain readable with larger text and browser zoom. Use the dot matrix as an optional display style for a large reading.
- Use padding from the card, with `--widget-padding-default` (18 px) and `--widget-padding-compact` (9–15 px, in 1 px steps at the default root size) as the shared baselines. Use the `--space-*` scale for internal gaps. Keep the card shape on `--radius-widget`. Controls use `--radius-control` or `--radius-pill` and shared heights. Keep icon-only controls square with matching minimum inline and block sizes. Use a pill for longer button labels.
- Use the Lumo `Button` with `size="xs"` by default in widgets. Keep full rows easy to tap when the row itself acts as a button.
- Use `--surface-raised` for the card, `--surface-muted` for secondary surfaces, and semantic text, border and status tokens. Keep the card itself static on hover. Use interactive states on actual interactive elements. Ensure status remains readable in both themes through a label, icon, or other non-color cue.
- Use the shared `Avatar` control and respect the avatar URL passed by the integrating application. Lumo demo avatars use 128 × 128 WebP with transparency. Keep larger portraits scoped to their own preview.

## Fit and overflow

- When space is tight, reduce content density first. Keep the main reading, unit and relevant status in Small. Add a trend or comparison in Medium, then more context in Large when it helps. Choose the smallest format that can present the essential content at the shared text sizes. [Apple HIG · Widgets](https://developer.apple.com/design/human-interface-guidelines/widgets#Displaying-text-in-widgets)
- Start with the source widget's format when adapting an existing widget. In the Studio choose `tile` for a short single-cell display, `summary` for a compact widget that needs a wider fallback, `reading` for medium, and `panel` for large. Use `homeScreen` for a panel that fills Home View and `canvas` for an intentionally full-width widget. Resolve the chosen profile with `apps/web/lib/studio-widget-sizes.ts` and let Studio measure natural content.
- Small and Medium standalone width tokens are `--widget-small-max-width` and `--widget-medium-max-width`. Large uses `--widget-large-max-width`. Fill the allocated Studio tile. On Home View use the existing safe area below full-screen content and a bounded inner scroll for tall content. Keep the outer viewport at its fixed height.
- Reserve layout space for optional actions, copy, readings, and pagination so the card keeps the same height at each width as users switch tabs or modes, swipe between pages, or scrub a chart. Use `WidgetDialog` for in-card detail overlays with thin internal scrolling.
- Whenever dots navigate between widget views, use both `WidgetPagination` from `@lumo/ui` and `useHorizontalSwipe` from `@lumo/hooks`. Connect both controls to the same active view and give each dot an accessible page name. Set `touch-action: pan-y pinch-zoom` on the swipe surface. Preserve vertical scrolling, clicks, and chart drags, and prevent the Studio pager from handling a swipe intended for the widget.
- Every scrollable list inside a widget must use `useScrollShadow` from `@lumo/ui` on the element that owns the overflow and set `scrollbar-width: thin` on that element. Match the hook's axis to the scroll direction and keep the list reachable by keyboard. Verify that the shadow appears only on edges with more content and disappears when all rows fit. `WidgetDialog` and the Studio Home View scroll region already provide the shadow and thin scrollbar.
- Use a segmented control for a small set of visible choices. For a longer selection list, anchor `WidgetDialog` with `placement="bottom"` inside the card. Show the current choice on the trigger and make selection dismiss the sheet. The handle accepts a press or a downward drag, and the content scrolls independently. By default, a downward drag dismisses the sheet after travelling 50% of its height. Use `dismissThresholdPercent` when a widget needs a different threshold.

## Data, charts and motion

- Use `WidgetChart` with inset placement by default. Opt in to `inline` or `bottom` bleed when the visualization is meant to reach the card edge and the labels and targets have room. Use a subtle curve-to-transparent fill using the series token where that helps read a trend. Preserve existing thresholds, true baselines and semantic colors. Use the shared `WidgetChartArea` for SVG trend fills in Lumo.
- Apply `data-widget-list` to the list container for comparable rows. Place selection and status on the row, so they retain visual priority over the alternate background. Use `--widget-list-row-alternate` and `--widget-list-row-radius` in layouts that need their own row styling.
- Use `AnimatedNumber` for changing values, `SlotText` for concise changing labels, and the motion tokens from `@lumo/tokens`. Use restrained fades, staggered entry and eased stops to clarify changes. Respect reduced-motion preferences. Keep a dragged chart cursor and its readout in sync during the drag and preserve its final position on release.
- Animate the fill of progress and comparison bars from the baseline when their view appears. On data changes, transition from the current fill to the new value in either direction. Keep the track and layout fixed, and show final proportions immediately with reduced motion. Add stationary diagonal hatching to the dark unfilled track with `--widget-track-hatch`. Keep the colored fill and its markers legible above the pattern.
- For optional dot-matrix displays, keep the main value available as accessible text and use the shared interface type for units and labels.
- Use the shared frame scheduler via `useAnimationInterval` for simulated cadence. Remove pause and resume controls that only operate the demo. Show a pause control for an actual operation the host can pause. For continuous pointer or animation updates, use motion values or `requestAnimationFrame` scoped to the visualization. Cancel work on unmount. Keep static subtrees stable while values update and add memoization when it prevents an actual repeated render.

## Accessibility and reduced motion

- Use native controls with accessible names and a visible focus indicator. Provide a keyboard alternative to pointer actions such as chart scrubbing or rearranging tiles. Keep the focus order logical and restore focus after dismissing a dialog.
- Check each supported theme and surface. Readable text needs at least 4.5:1 contrast for regular text or 3:1 for large text. Identify important states with a label or an icon alongside color. [WCAG contrast guidance](https://www.w3.org/WAI/WCAG22/Understanding/contrast-minimum.html)
- Include the reading and its unit in accessible text. Give charts a summary or an equivalent data table. Keep decorative marks and animated digit copies out of the accessibility tree. Announce meaningful updates once and keep recurring readings quiet unless the user needs an alert.
- Respect `prefers-reduced-motion` in CSS and the user's reduced-motion preference in JavaScript, including Motion transitions and frame loops. Show complete charts, settled values and available controls immediately in reduced mode. Disable decorative movement, including scrolling effects, looping pulses, and rolling digits. Provide a way to pause or stop essential continuous animation. [WCAG motion guidance](https://www.w3.org/WAI/WCAG22/Understanding/animation-from-interactions.html)
- Before shipping a widget, verify it with keyboard and pointer input, with reduced motion on and off, and in its narrowest supported layout. Use the [live accessibility example](/design-system#accessibility) as a reference.

## Forms

- Use form controls from `@lumo/ui` in widgets and their demos. Reuse the shared Input, Textarea, NumberField, Select and Button where appropriate. When a control is missing, adapt the corresponding primitive from the local Arc UI source into Lumo UI with shared tokens and the original licence.
- Define each submission's Zod schema in a separate file. Parse and normalize input on submit, infer payload types from the schema, and call the integration callback only after successful validation. Document the accepted fields and any constraints in the widget's API or data contract.
- Connect Zod field errors to the relevant input and focus the first invalid field. Use the shared form error for a rejected submission, keep the entered values for a retry, and prevent duplicate requests while awaiting a result. Handle success and validation feedback with the same accessible controls in the demo.

## Integration and verification

- Expose typed inputs, units, and callbacks independently of demo data. Keep the component reusable with controlled inputs when an integrator owns state. Document the public API and a representative dataset. Keep components, substantial constants, types and stateful hooks in separate files when they serve distinct purposes.
- On the Code page, document the data the host needs to fetch, transform and refresh. Describe required and optional fields, units, date formats, missing-data behavior, and calculations the widget performs. For data that needs aggregation or normalization, include a provider-neutral example that maps a host payload to the typed props.
- Verify the actual widget on narrow mobile and desktop, plus the relevant Studio profiles and Home View. At each width, compare the card height before, during, and after interactions that change its content, including long labels and missing readings. Check keyboard and touch interactions, light and dark themes, and reduced motion. For published widgets, verify the code view and ZIP still include the files, styles and assets used.

## Publication

- The collection shows **In progress** until a version passes the design, accessibility, and integration review. Enter its exact version as `validatedVersion` under its canonical widget ID in `apps/web/lib/widget-publication.ts`. A version bump calls for reviewing the new version.
- A validated free widget shows **Validated** and offers its usage, API, sample data, source files, and ZIP. Set `tier: "pro"` for a widget selected for the paid pack. Its collection status is **Locked** and its interactive preview is available.
- Keep source access in the shared server loader used by the code page and ZIP. Use the collection and the preview page to verify both the visible status and direct access to the download endpoint.
- Create collection posters in the Lumo theme at 16:9. For a supplied recording, choose a readable frame and crop it to keep the whole widget visible. For a widget-only capture, extend the widget surface to the square corners of the image. The media frame provides the outer border and rounding. Keep posters in `apps/web/public/showcase` and register recordings hosted at `https://code-dev.pro/production/lumo/videos/` in `apps/web/lib/showcase-routes.ts`. Preserve the exact case of each video filename.

In Lumo, start with `packages/tokens/src/tokens.css`, `packages/tokens/src/motion-tokens.ts`, and `packages/ui/src/widget-card/`. The page at `/design-system` exercises these rules with live components.
