# Theme widget

One hue moves the accent and the background tint together; the button fill is solved per hue so its text stays at AA. Contrast softens or strengthens borders, fills and text around a fixed panel and card: AA at least, AAA at max.

## What it changes

The widget drives the whole page: the surfaces, text and controls around it move with every change. Leaving the page restores the brand.

## In a popover

The app opens it in a popover, from an Appearance row. Every copy on a page shares one state.

## Examples

```svelte
<script lang="ts">
  import Button from '@qualia-studios/design-ui/components/Button.svelte';
  import Card from '@qualia-studios/design-ui/components/Card.svelte';
  import Popover from '@qualia-studios/design-ui/components/Popover.svelte';
  import ThemeWidget from '@qualia-studios/design-ui/components/ThemeWidget.svelte';
  import { ThemeState } from '@qualia-studios/design-ui/theme';

  const theme = new ThemeState();
</script>
```

### Example 1: The controls

```svelte
<ThemeWidget {theme} />
```

### Example 2: What the controls move

Surfaces, text and controls, toned by the widget.

```svelte
<div class="sample">
  <Card>
    {#snippet header()}Run summary{/snippet}
    {#snippet body()}
      <p>
        Body text on a card, with a <a href="#top">link in the accent</a>.
      </p>
      <p class="muted">Muted label text</p>
      <p class="subtle">Subtle hint text</p>
      <div class="actions">
        <Button tone="primary">Primary</Button>
        <Button tone="primary" variant="outlined">Outlined</Button>
      </div>
    {/snippet}
  </Card>
  <label class="well">
    <span>Input on an inset well</span>
    <input placeholder="Placeholder" />
  </label>
</div>
```

### Example 3: In a popover, from an Appearance row

The same state as the controls above.

```svelte
<Popover class="trigger" align="start">
  {#snippet trigger()}
    Appearance
  {/snippet}
  <ThemeWidget {theme} />
</Popover>
```

---

From the Qualia design guide: https://q-core-3b2732.gitlab.io/components/themewidget. Every page as markdown: https://q-core-3b2732.gitlab.io/llms.txt
