# Icon

The `Icon` wrapper draws a [Phosphor](https://phosphoricons.com/) icon at a size, a tone and a weight. Phosphor ships six weights and we default to **regular** for its balance of legibility and density. Which icons there are, and their names, is a token: see [Icons](https://q-core-3b2732.gitlab.io/tokens/icons.md).

## Sizes

Five sizes, each a pixel square; `md` sits beside body text.

## Tones

Without a tone the icon takes the text colour; `primary` takes the accent, and the status tones match a message's severity.

## Weights

Four line weights, **regular** the default, and two filled ones for a selected or emphatic state.

## Examples

```svelte
<script lang="ts">
  import CheckIcon from 'phosphor-svelte/lib/CheckIcon';
  import StarIcon from 'phosphor-svelte/lib/StarIcon';
  import Icon from '@qualia-studios/design-ui/components/Icon.svelte';
  import { sizes } from '@qualia-studios/design-ui/components/Icon.svelte';

  const allSizes = Object.keys(sizes) as Array<keyof typeof sizes>;
  const accents = [undefined, 'primary'] as const;
  const statuses = ['success', 'warning', 'danger', 'info', 'help'] as const;
  const lines = ['thin', 'light', 'regular', 'bold'] as const;
  const fills = ['fill', 'duotone'] as const;
</script>
```

### Example 1: The size scale

```svelte
<div class="row">
  {#each allSizes as s (s)}
    <div class="labeled">
      <Icon icon={StarIcon} size={s} />
      <code class="label">{s} · {sizes[s]}px</code>
    </div>
  {/each}
</div>
```

### Example 2: Default and accent tones

```svelte
<div class="row">
  {#each accents as tone (tone ?? 'default')}
    <div class="labeled">
      <Icon icon={CheckIcon} size="lg" {tone} />
      <code class="label">{tone ?? 'default'}</code>
    </div>
  {/each}
</div>
```

### Example 3: Status tones

```svelte
<div class="row">
  {#each statuses as tone (tone)}
    <div class="labeled">
      <Icon icon={CheckIcon} size="lg" {tone} />
      <code class="label">{tone}</code>
    </div>
  {/each}
</div>
```

### Example 4: Line weights

```svelte
<div class="row">
  {#each lines as weight (weight)}
    <div class="labeled">
      <Icon icon={StarIcon} size="lg" {weight} />
      <code class="label">{weight}</code>
    </div>
  {/each}
</div>
```

### Example 5: Filled weights

```svelte
<div class="row">
  {#each fills as weight (weight)}
    <div class="labeled">
      <Icon icon={StarIcon} size="lg" {weight} />
      <code class="label">{weight}</code>
    </div>
  {/each}
</div>
```

---

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