Expand commentComment on line R9Resolved

Icon

The Icon component provides a consistent way to display Material Symbols and custom SVG icons across Halstack applications. It helps users recognize actions, understand information, and navigate interfaces through visual representation while maintaining consistency in appearance, sizing, color and accessibility.

Usage

Use the Icon component to visually support actions, communicate information, and reinforce the meaning of interface elements.

Icons can be used independently for visual representation or alongside text to provide additional context.

When to use

  • Actions: Represent actions within interactive components, such as edit, delete, search, close, and add.
  • Navigation: Help users identify navigation destinations and controls.
  • Feedback: Communicate statuses such as success, warning, error, and information.
  • Content: Represent objects, concepts, and categories.
  • Communication and media: Represent messaging, notifications, audio, and video functionality.

When not to use

  • Do not use an icon as the only source of information when its meaning is unclear.
  • Do not use icons as decorative replacements for text when a label is necessary to understand an action.
  • Do not use an icon as an interactive element on its own. When an action is required, use an appropriate interactive component, such as Button, and use the icon to visually represent the action within it.

Resources

Halstack uses Material Symbols as its primary icon resource and supportscustom SVG icons when an appropriate Material Symbol is unavailable.

Material Symbols

Material Symbols are the primary icon resource used by Halstack. They provide a consistent visual language and a predefined collection of commonly used interface icons.

The component supports the following Material Symbols styles:

Material Symbols variants
  • Outlined: The default style, suitable for more general-purpose interface scenarios.
  • Filled: Used when additional visual emphasis or distinction is needed.

Custom SVG icons

The component also supports custom SVG icons when an appropriate Material Symbol is unavailable.

When using custom SVGs:

  • Use optimized SVG assets.
  • Follow the same visual proportions and alignment as the existing icon library.
  • Ensure that the SVG scales correctly and remains recognizable at different sizes.
  • Define the SVG's colors within the asset or use currentColor when parent color inheritance is desired.

Note: Custom SVG icons retain their original appearance and are not affected by the Material Symbols visual styles. Their colors can be defined directly in the SVG or configured to inherit from the parent.

Accessibility

Icons should be accessible to all users, including those using assistive technologies. Their accessibility requirements depend on the purpose and context in which they are used.

Decorative icons

Icons that are purely decorative or redundant with nearby text should be hidden from screen readers to avoid unnecessary announcements.

Meaningful icons

Icons that communicate meaningful information should have an accessible name that clearly describes their purpose. Avoid relying on an icon alone when additional text or context is necessary to understand its meaning.

Icons within interactive components

When an icon is used inside a Button or Link, the parent component should provide the accessible name and interaction semantics. The nested Icon should remain hidden from screen readers to avoid duplicate announcements.

Implementation notes

The Icon component provides a consistent interface for displaying Material Symbols and custom SVG icons in Halstack.

Icon selection

  • Material Symbols should be selected using their predefined Material Symbols names.
  • Original Material Symbols names should be preserved.
  • Custom SVGs can be provided when an icon is not available in the existing Material Symbols library.

Size

Use available Halstack height tokens to define icon sizes when an explicit size is required.

  • Material Symbols: Inherit their font size from the parent element. When used standalone, they inherit the font size of the <body> element.
  • Custom SVGs: Do not automatically inherit their size from the parent element. They have a default size of 24px and can use available Halstack height tokens when a different size is needed.

Commonly used sizes include:

Icon sizes
  • 16px: For compact UI elements.
  • 20px: For medium-sized interactions.
  • 24px: Standard Material Symbol size and default custom SVG size.

Commonly used icon sizes include 16px, 20px, and 24px. These are examples and do not limit the available Halstack size tokens.

Color

Material Symbols inherit their color from their parent element by default, allowing them to remain visually consistent with surrounding text and interface components.

For custom SVG icons, color inheritance depends on how the SVG is defined. SVGs usingcurrentColor inherit the color from their parent element, while SVGs with hardcoded fill or stroke values retain their defined colors.

Color should not be the only means of communicating information. Provide additional visual or textual context when necessary.

Behavior

The Icon component is primarily visual and does not manage independent interaction states.

Parent components are responsible for handling interaction and semantic states, such as hover, focus, active, and disabled.

This approach keeps the Icon component reusable while allowing it to adapt to the behavior and context of its parent component.

Best practices

  • Use Material Symbols whenever possible: Prefer Material Symbols when an appropriate icon is available to maintain consistency across Halstack applications.
  • Choose the appropriate visual style: Use Outlined as the default style. Choose Filled when additional emphasis or visual distinction is needed.
  • Maintain visual consistency: Ensure custom SVG icons follow the proportions, alignment, and visual weight of the existing icon library.
  • Use icons purposefully: Choose icons that clearly support the meaning or function of the surrounding content. Avoid using icons without a clear purpose.
  • Provide accessible context: Ensure meaningful icons have an accessible name. Pair icons with text when their meaning may not be immediately recognizable.
  • Use appropriate interactive components: When an icon represents an action, place it within an appropriate interactive component, such as a Button, button link, or link, rather than treating the icon itself as interactive.