Mushilu-San UI

Search components

PlaygroundStorybookGitHub
Primitives

Icon

A set of built-in outline icons, sized and coloured with the surrounding text.

Selector: mui-icon

Import
import { Icon } from '@mushilu-san/ui/primitives';
PreviewCode

Loading example…

Overview

Icon draws an SVG from a fixed set of names. It uses currentColor, so it takes the colour of its parent unless color is set.

An icon without a label is decorative and hidden from assistive technology. Set label when the icon carries meaning on its own, and the icon gets role="img".

When to use

  • Supporting a text label, such as a mail icon next to an email address.
  • Icon-only controls, where the icon is wrapped in a button that has its own accessible name.

When not to use

  • A decorative picture or illustration. Use an image.
  • An icon with no text and no label. The meaning is lost for screen reader users.

Examples

Labelled and mirrored

Directional icons such as arrows and chevrons use mirror so they point the right way in RTL.

PreviewCode

Loading example…

Guidelines

Do

  • Use mirror for arrows and chevrons that indicate direction.
  • Put a visible text label next to an icon whenever possible.

Don't

  • Do not use mirror on icons that are not directional, such as a search or a star icon.
  • Do not use label on an icon inside a button that already has a name. The name would be read twice.

Accessibility

Roles and attributes

ElementRoleNotes
host, no label—aria-hidden="true".
host, with labelimgaria-label is set from label.
  • An icon is not focusable. For an icon-only action, use a Button with an aria-label on the button.

API

Icon

Selector: mui-icon

NameTypeDefaultDescription
namerequired'arrow-left' | 'arrow-right' | 'bell' | 'calendar' | 'check' | 'check-circle' | 'chevron-down' | 'chevron-left' | 'chevron-right' | 'chevron-up' | 'copy' | 'download' | 'edit' | 'external-link' | 'eye' | 'eye-off' | 'filter' | 'heart' | 'home' | 'info' | 'loading' | 'mail' | 'map-pin' | 'menu' | 'minus' | 'more-horizontal' | 'more-vertical' | 'phone' | 'plus' | 'search' | 'settings' | 'star' | 'trash' | 'upload' | 'user' | 'x'— Name of the built-in icon to draw.
size'sm' | 'md' | 'lg' | 'xs' | 'xl''md' Icon size: `xs` (12px) to `xl` (32px). Default `md` (20px).
color'primary' | 'inherit' | 'muted' | 'danger' | 'success' | 'warning''inherit' Icon colour from the semantic palette. `inherit` uses the surrounding text colour.
labelstring | undefined— Accessible name. When set the icon is announced as an image; when empty it is hidden from assistive technology.
mirrorbooleanfalse Flip horizontally in RTL. Use for directional icons (chevrons, arrows). Accepts attribute presence, e.g. <… mirror>.

CSS parts

  • ::part(root)

Tokens

  • --mui-color-text
  • --mui-color-primary
  • --mui-color-danger
  • --mui-color-success
  • --mui-color-warning
  • --mui-color-text-muted