Icon
Render decorative or named icons from utility names or JSX.
Use Icon for decoration or a named symbol alongside text. If the icon alone conveys meaning, give it an accessible name; otherwise it is hidden from assistive technology.
Basic usage#
Playground#
Anatomy#
Usage#
Icon sources#
Pass a supported icon name, JSX element, or component source. Use an icon as decoration only when adjacent text already names the meaning; otherwise provide an accessible label on the meaningful control or icon.
Use <Icon name="icon-search" /> or <Icon name="icon-success" /> for Moraine’s semantic aliases. Editor completion suggests the built-in names, while <Icon name="i-lucide-search" /> and <Icon name="app-logo" /> remain valid. Icon applies string names as classes; your UnoCSS or Tailwind setup must generate the corresponding CSS for custom names.
Solid control-flow nodes such as <Show>, <For>, and <Switch> are not supported as the top-level name value. Keep control flow outside Icon so it owns whether the component is rendered:
Root styling#
Icon has one rendered root. Use class and style for an individual icon, or configure icon.base.root in your Theme for shared defaults. classes and styles are not instance props because there are no child slots to target. slotName only changes the emitted data-slot value.
Examples#
JSX icon#
Accessibility#
Props#
Props for the Icon component. Renders a <div> element by default.