# LogoIcon

> SVG icon inlined in the page at build time.

The file is read at build time and its content placed in the page. That is
what lets it take its colour from `currentColor` and be sized like the rest of
the text — impossible through an `img` tag, which isolates the document.

## An icon

<LogoIcon src="/versions/v0.2/components/icons/book.svg" label="Documentation" />
<LogoIcon src="/versions/v0.2/components/icons/star.svg" label="Favourite" />
<LogoIcon src="/versions/v0.2/components/icons/lightning.svg" label="Fast" />
<LogoIcon src="/versions/v0.2/components/icons/shield.svg" label="Verified" />

```mdx
<LogoIcon src="./icons/book.svg" label="Documentation" />
```

A relative path starts from the page, an absolute path from the version
folder. Nothing can leave it: a page does not read the rest of the machine.

## It follows the text

Placed in a text, the icon takes its size and colour.

<ForTheme framework="tailwind">

<div className="text-indigo-600 text-2xl">
  <LogoIcon src="/versions/v0.2/components/icons/star.svg" /> at the size and colour of the text
</div>

<div className="text-sm text-slate-500">
  <LogoIcon src="/versions/v0.2/components/icons/star.svg" /> and here, smaller and greyer
</div>

</ForTheme>
<ForTheme framework="custom">

<div className="accent-text large">
  <LogoIcon src="/versions/v0.2/components/icons/star.svg" /> at the size and colour of the text
</div>

<div className="small muted">
  <LogoIcon src="/versions/v0.2/components/icons/star.svg" /> and here, smaller and greyer
</div>

</ForTheme>

## Sizes

`size` accepts any CSS length.

<div style={{ display: 'flex', alignItems: 'flex-end', gap: '1rem', color: '#10b981' }}>
  <LogoIcon src="/versions/v0.2/components/icons/shield.svg" size="1rem" />
  <LogoIcon src="/versions/v0.2/components/icons/shield.svg" size="2rem" />
  <LogoIcon src="/versions/v0.2/components/icons/shield.svg" size="3rem" />
  <LogoIcon src="/versions/v0.2/components/icons/shield.svg" size="4rem" />
</div>

<ForTheme framework="tailwind">

```mdx
<LogoIcon src="./icons/shield.svg" size="3rem" style={{ color: '#10b981' }} />
```

</ForTheme>
<ForTheme framework="custom">

```mdx
<LogoIcon src="./icons/shield.svg" size="3rem" className="green" />
```

`green` comes from `theme/99-docpensieve.css`, and sets `color`.

</ForTheme>

The colour only follows if the file relies on `currentColor` rather than on a
fixed colour.

## In a list

<ul style={{ listStyle: 'none', paddingInlineStart: 0, display: 'grid', gap: '0.5rem' }}>
  <li style={{ display: 'flex', alignItems: 'center', gap: '0.5rem' }}>
    <LogoIcon src="/versions/v0.2/components/icons/lightning.svg" size="1.1rem" style={{ color: '#f59e0b' }} /> No script to
    load
  </li>
  <li style={{ display: 'flex', alignItems: 'center', gap: '0.5rem' }}>
    <LogoIcon src="/versions/v0.2/components/icons/shield.svg" size="1.1rem" style={{ color: '#10b981' }} /> Links are read
    back before publishing
  </li>
  <li style={{ display: 'flex', alignItems: 'center', gap: '0.5rem' }}>
    <LogoIcon src="/versions/v0.2/components/icons/book.svg" size="1.1rem" style={{ color: 'var(--dp-accent)' }} /> One
    version per branch
  </li>
</ul>

## At the head of a card

<Columns>
  <Column span={6}>
    <Card style={{ height: '100%' }}>
      <CardBody>
        <LogoIcon src="/versions/v0.2/components/icons/lightning.svg" size="1.6rem" style={{ color: '#f59e0b' }} />
        <strong style={{ display: 'block', margin: '0.5rem 0 0.25rem', fontSize: '1rem' }}>Fast</strong>

        No hydration, no bundle to download before reading.
      </CardBody>
    </Card>

  </Column>
  <Column span={6}>
    <Card style={{ height: '100%' }}>
      <CardBody>
        <LogoIcon src="/versions/v0.2/components/icons/shield.svg" size="1.6rem" style={{ color: '#10b981' }} />
        <strong style={{ display: 'block', margin: '0.5rem 0 0.25rem', fontSize: '1rem' }}>Verified</strong>

        Dead links and invalid markup stop the publication.
      </CardBody>
    </Card>

  </Column>
</Columns>

## Decorative or meaningful

Without `label`, the icon is treated as decorative and hidden from screen
readers — which is right when nearby text already says the same thing. With
`label`, it becomes a described image.

```mdx
<LogoIcon src="./icons/star.svg" />
<LogoIcon src="./icons/star.svg" label="Favourite" />
```

In the list above, the icons have no `label`: the text next to them already
carries the meaning, and announcing it twice would tell nothing.

## What it refuses

A missing file, a file without an `svg` tag, a target leaving the version
folder: each one stops the build, naming the expected path. A missing icon
would otherwise leave an empty box that nobody notices.

The scripts and event handlers present in a file are removed before inlining.
A component loads no JavaScript, and this one is not going to introduce any.
