# Theme View

ThemeView is a headless component that displays the current theme name as inline text. It renders the theme value in a `<span>` element with an accessible label, making the current theme selection readable by screen readers.

**Status:** stable — exercised in composed page flows under e2e and axe, beyond the per-component checks.

This component is commonly paired with ThemeSelect in an Input/View pattern. While ThemeSelect allows the user to select a theme, ThemeView displays the currently active theme. It is useful in settings panels, status bars, or anywhere the current theme needs to be communicated visually and programmatically.

## Implementation Notes

- Renders a `<span>` element containing the theme value as text content
- No ARIA on the root: a plain `<span>` cannot be named. A visible caption names the value, or `label` renders as hidden text in a `.screen-reader-span`
- Both `label` and `value` are required props
- Spreads `restProps` onto the span for consumer customization
- pattern: standard props destructuring with typed props

## Props

- `label`: string (optional) — hidden text naming the value, in a `.screen-reader-span`. Leave it out when a visible caption names the value
- `value`: string (required) -- the current theme name to display as text content
- `...restProps`: unknown -- additional attributes spread onto the `<span>` element

## Usage

Display the current theme in a settings summary:

```html
<ThemeView
  label="Current theme"
  value="dark"
/>
```

In a summary list alongside other preferences:

```html
<SummaryList>
  <SummaryListItem>
    <dt>Theme</dt>
    <dd>
      <ThemeView
        label="Current theme"
        value="{currentTheme}"
      />
    </dd>
  </SummaryListItem>
  <SummaryListItem>
    <dt>Language</dt>
    <dd>English</dd>
  </SummaryListItem>
</SummaryList>
```

In a status bar showing the active theme:

```html
<footer>
  <ThemeView
    label="Active theme"
    value="{theme}"
    data-theme="{theme}"
  />
</footer>
```

## Keyboard Interactions

None -- this component is a passive display element with no interactive behavior.

## ARIA

## When to Use

- Use to display the current theme in read-only format in settings summaries and status bars.
- Use in confirmation screens where the user has just selected a theme and needs to see it confirmed.
- Use when displaying the active theme alongside other user preferences.
- Use in admin panels to show the theme assigned to a user or organisation.

## When Not to Use

- Do not use when users need to select or change the theme -- use [ThemeSelect](theme-select.md) instead.
- Do not use for general-purpose text display -- use a `<span>` or [Badge](badge.md) instead.

## Headless

This headless component provides a `<span>` element with `aria-label` for accessible read-only theme display. The consumer provides all visual styling, including typography, color, and layout.

## Styles

The consumer provides all CSS styling. The component renders with a `.theme-view` class for targeting. No default styles are included — this is a fully headless component.

## Testing

- Verify the component renders a `<div>` element with class `theme-view`
- Verify `label` renders as hidden text, and that the root has no `aria-label`
- Verify pass-through attributes are applied

## Advice

- **Designers**: Style the theme name to visually reflect the current theme (e.g., dark text for dark mode label) so users can confirm at a glance.
- **Developers**: Keep the `value` prop in sync with the actual applied theme so the display is always accurate.

## Composition

ThemeView is the read-only display counterpart to ThemeSelect. Use ThemeView to show the current theme, and pair it with ThemeSelect for editing.

## Related components

- `theme-select` — a select dropdown for choosing a theme

## Known limitations

None known.

## References

- WAI-ARIA Accessible Name: https://www.w3.org/TR/accname-1.2/

---

Lily™ and Lily Design System™ are trademarks.
