Icons and fonts

Use Salla Icons in your components, follow the merchant's font, and add your own font or icon font to a theme.

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

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.

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

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 with Import Icons.

The merchant's 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:

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 for the colour variables.

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:

brand.woff2
app.css
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.

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.

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

  • 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 already use it when the store has it on.

See also

On this page