Skip to content

Frontend icon guidelines

This guide describes how frontend code renders icons from the Design System icon set and where the legacy class-based icons still apply. Component APIs and the full catalog live in Storybook and in app/frontend/src/design_system/primitives/icon/.

Discover icons in Storybook

Find the icon name in Storybook before writing code (see Discover components for the URLs):

  • In Design System Components/Primitives/Icon, the AllIcons story lists every name; the Default story previews sizes, appearances, and spin.
  • The same names are the DSIconName union in primitives/icon/types/iconName.generated.ts. It is generated, so do not edit it.

Do not copy SVG markup into components or add files to app/frontend/public/icons/ for a single feature.

Prefer the consuming component's icon prop

When a DS component already places an icon, pass the name to its prop instead of nesting DSIcon in a slot. The component then picks the matching icon size and spacing.

Component Icon props
DSButton prefixIcon, suffixIcon (icon size follows the button size)
DSButtonGroup options (DSButtonGroupOption) prefixIcon, suffixIcon
DSTag prefixIcon
<DSButton prefix-icon="plus">{{ addLabel }}</DSButton>

In Rails, use the matching helper option, for example ds_button(..., prefix_icon: "plus").

Use DSIcon for standalone icons

Use DSIcon (default import from @/src/design_system/primitives/icon/components/DSIcon.vue) only where no component prop fits, for example an icon next to a label. In Rails, use ds_icon(icon:, appearance:, size:).

Prop Values Default
icon DSIconName required
size DS_ICON_SIZES: xs, sm, md, lg, xl md
appearance DS_ICON_APPEARANCES: outlined, filled outlined
spin boolean, for loading indicators false

Use the DS_ICON_SIZES and DS_ICON_APPEARANCES constants from primitives/icon/types in script code instead of string literals. Do not resize or recolour the icon with custom CSS; choose a supported size and let the icon inherit the text color.

Type icon names with DSIconName

Type every prop, constant, or map that holds an icon name as DSIconName, never string. tsc then rejects unknown or removed names.

import type { DSIconName } from "@/src/design_system/primitives/icon/types/iconName.generated";

type ExportStatus = "done" | "failed";

const STATUS_ICON = {
  done: "c-check",
  failed: "c-warning",
} as const satisfies Record<ExportStatus, DSIconName>;

See Type constant maps for the satisfies pattern.

Separate decorative icons from labelled actions

  • Decorative icon next to visible text: the text carries the meaning. Mark a standalone DSIcon with aria-hidden="true", as DS components such as DSTag and DSCard do.
  • Icon-only action: set ariaLabel (aria_label in Rails) with a translated text describing the action, not the icon. The IconOnly story in DSButton.stories.ts shows the required pattern.
  • Informative standalone icon (for example a c-info hint): put the meaning into an accessible element, such as a tooltip on a focusable control or visible text. Do not rely on the icon shape alone.
<DSButton
  prefix-icon="bin"
  variant="ghost"
  :aria-label="deleteLabel"
  @click="removeItem"
/>

Keep legacy font icons in legacy code

Two class-based icon systems remain for server-rendered and legacy markup. Do not use them in new Vue code or new DS components:

  • icon icon-<name> font icons, defined in app/frontend/src/shared/stylesheets/easy/variables/_icons.scss (Storybook: Legacy Components/Primitives/Legacy Icon (Class based); markup in Legacy HTML patterns).
  • ds-legacy-icon ds-legacy-icon__<name> classes for DS icons in markup that cannot render a component, whitelisted in primitives/icon/stylesheets/_abstracts/legacy-icon.variables.scss (Storybook: Legacy Components/Primitives/Legacy DSIcon (Class-based)).

The names of these systems differ from DSIconName. When you touch legacy markup that can render a DS component or helper, replace the class with DSIcon, ds_icon, or the component's icon prop instead of extending the legacy lists.