Skip to main content

Icons

Built-in Lucide mask icons, Icon component, component icon props, and interactive icon gallery.

View as Markdown

Moraine provides built-in CSS mask styles for Lucide icons. Mask icons render as pure CSS and inherit the current text color and font size, so no runtime SVG is loaded.

Zero-Config Setup#

To enable built-in icons, import Moraine’s icon stylesheet in your main application entry:

src/index.css
@import 'moraine/icon.css';

The stylesheet puts its rules in the components cascade layer and sizes each icon at 1.2em. <Icon> renders every icon in a span, and a size utility such as size-4 on the icon overrides that size in both UnoCSS and Tailwind. For a JSX or component icon, Icon renders a 1.2em span that the graphic fills.

The <Icon> Component#

Render standalone icons with the <Icon> component:

import { Icon } from 'moraine'

export function SearchIndicator() {
  return <Icon name="icon-search" class="text-primary text-lg" />
}

Component Icon Props#

Button and Badge accept leading and trailing icon props, as do Select, Combobox, and MultiSelect. Tabs items take an icon. To add an icon to an Input, wrap it in InputGroup:

import { Button, Icon, Input, InputGroup } from 'moraine'

export function SearchBar() {
  return (
    <div class="flex items-center gap-2">
      <InputGroup>
        <InputGroup.Leading>
          <Icon name="icon-search" />
        </InputGroup.Leading>
        <Input aria-label="Search components" placeholder="Search components..." />
      </InputGroup>
      <Button leading="icon-plus" variant="solid">
        New Item
      </Button>
    </div>
  )
}

The published stylesheet includes Moraine’s semantic aliases such as icon-search and icon-chevron-down. Other names, such as i-lucide-search, need their own CSS generator, for example UnoCSS’s presetIcons() with the Lucide collection. Passing an icon name does not load its CSS.

Browse the built-in icon-* aliases below. Click an icon to copy its name to your clipboard: