# Icons and fonts (https://docs.salla.dev/twilight/react/guide/icons-and-fonts)



Read this when you want an icon in your theme, or a font other than the one the merchant picked.

## Salla Icons [#salla-icons]

**Salla Icons** is an icon font: each icon is a class name that starts with `sicon-`. The engine loads it on every page, so you add nothing to use it.

```tsx title="app/components/header/CartButton.tsx"
export function CartButton({ count }: { count: number }) {
  return (
    <button aria-label="Cart">
      <i className="sicon-cart" aria-hidden="true" />
      <span>{count}</span>
    </button>
  );
}
```

An icon takes the text colour and font size of its parent, so style it with `color` and `font-size` like text.
Give icon-only buttons an `aria-label`, and mark the icon itself `aria-hidden="true"`.

### Find an icon [#find-an-icon]

Every icon name is listed in the stylesheet the engine loads:
`https://cdn.assets.salla.network/static/fonts/sallaicons.css`. Search it for a word such as `cart`, `heart` or `search`.

To browse them as pictures, import the icon file `https://cdn.salla.network/fonts/lib/sallaicons/sallaicons.svg`
into [IcoMoon](https://icomoon.io/app/#/select) with **Import Icons**.

## The merchant's font [#the-merchants-font]

The merchant picks the store font in the dashboard. The engine loads it and sets the CSS variable `--font-main`, so use that variable for text:

```css title="app/styles/app.css"
body {
  font-family: var(--font-main);
}
```

The merchant can change the font only when your `twilight.json` lists the `"fonts"` feature. The same goes for the main colour and `"color"`.
See [Styling](https://docs.salla.dev/twilight/react/guide/styling#colour-and-font-tokens) for the colour variables.

## Add your own font [#add-your-own-font]

Put the font files next to your styles and declare them with `@font-face`. Vite finds the files from the relative `url()`, adds them to the build and fixes the paths:

<Files>
  <Folder name="app/styles">
    <Folder name="fonts">
      <File name="brand.woff2" />
    </Folder>

    <File name="app.css" />
  </Folder>
</Files>

```css title="app/styles/app.css"
@font-face {
  font-family: 'Brand';
  src: url('./fonts/brand.woff2') format('woff2');
  font-display: swap;
}

h1,
h2 {
  font-family: 'Brand', var(--font-main);
}
```

Keep `var(--font-main)` as the fallback, so text still follows the merchant's font while yours loads.

<Callout type="warn">
  A fixed font for all text takes the font choice away from the merchant. Use your own font for headings or a logo, and keep `--font-main` for body text.
</Callout>

## Add your own icon font [#add-your-own-icon-font]

An icon font from IcoMoon or a similar tool is a font plus a stylesheet of classes. Add both the same way:

1. Put the font files in `app/styles/fonts/`, and the generated CSS in `app/styles/`.
2. Fix the `url()` paths in that CSS to point at `./fonts/...`.
3. Import the CSS from `app/styles/app.css`.

Give your classes their own prefix, such as `my-icon-`, so they never clash with `sicon-`.

## Gotchas [#gotchas]

* The Salla Icons stylesheet loads without blocking the page, so icons can appear a moment after the text. Do not use an icon as the only label of a button.
* Files in `public/` are served as they are, without a hash. Prefer files next to your styles, so a changed font is never served from an old cache.
* `sicon-sar` is the Saudi riyal symbol. Prices from [`useMoney`](https://docs.salla.dev/twilight/react/hooks/use-money) already use it when the store has it on.

## See also [#see-also]

* [Styling](https://docs.salla.dev/twilight/react/guide/styling)
* [twilight.json](https://docs.salla.dev/twilight/react/guide/twilight-json)
* [Project structure](https://docs.salla.dev/twilight/react/start/project-structure)
