> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# Icon

195 vector icons from the [Lucide](https://lucide.dev) set, drawn with Lynx's `<svg>` element. It draws your own SVG too, such as a sign-in provider's mark.


## Installation

```bash
npx @blotch/dolan add icon
```

```typescript
import { UiIcon, provideIcons } from '../components/ui/icon';
```

## Usage

Register the icons your app draws, then draw them by name:

```typescript title="src/app/app.config.ts"
import { heartIcon, provideIcons } from '../components/ui/icon';

export const appConfig: ApplicationConfig = {
  providers: [
    // ...
    provideIcons({ heartIcon }),
  ],
};
```

```typescript title="src/app/app.ts"
import { Component } from '@angular/core';
import { UiIcon } from '../components/ui/icon';

@Component({
  selector: 'app-root',
  imports: [UiIcon],
  template: `<ui-icon name="heart" size="lg" color="#ef4444" />`,
})
export class App {}
```

### Register the icons you draw

Each icon is an export of its own, named for the icon with `Icon` on the end: `heart` is `heartIcon`, and `chevron-right` is `chevronRightIcon`.

`provideIcons()` registers the ones you pass, and only those go into your app's scripts. A set that every icon came with, whatever an app drew, took about 34 kB of the main-thread script. And Lynx keeps a script's whole bytecode in memory.

- **Register an icon wherever you draw it by name.** That's `name` on an icon, and `icon` on an [Empty State](/dolan/empty-state.md). It's also `icon` on the items of a [Tab Bar](/dolan/tab-bar.md), a [Dock](/dolan/dock.md), a [Menu](/dolan/menu.md), a [Toolbar](/dolan/toolbar.md) or a [Navigation Bar](/dolan/navigation-bar.md).
- **A name bound from data,** as in `[name]="item.icon"`, needs each icon the data can hold.
- **The components' own icons need nothing.** A calendar's chevrons, a search field's magnifier or a copy button's check are registered by the component that draws them.
- **Give it in the app's config for the whole app, or in a component's `providers`** for that component and everything it shows. Each `provideIcons()` adds to the icons registered above it, so a feature can register its own icons where it draws them.
- **An icon nobody registered throws** an error that names its export, such as `No icon named "chevron-right" is registered. Register it with provideIcons({ chevronRightIcon })`, rather than drawing an empty box.
- **The keys don't matter:** each icon carries its own name, so `provideIcons({ heartIcon })` registers `heart`.

```typescript title="src/app/settings/settings.ts"
import { Component } from '@angular/core';
import {
  UiIcon,
  bellIcon,
  lockIcon,
  provideIcons,
} from '../../components/ui/icon';

@Component({
  selector: 'app-settings',
  imports: [UiIcon],
  // Only this screen draws these, so it registers them itself.
  providers: [provideIcons({ bellIcon, lockIcon })],
  template: `
    <ui-icon name="bell" />
    <ui-icon name="lock" />
  `,
})
export class Settings {}
```

To draw any icon by a name you can't list, such as names from a server, register the whole set with `provideAllIcons()`. It brings every icon back into your app's scripts.

Specs render components without the app's config, so they need the icons registered too. Export the same `provideIcons()` from the file your `test` target names as `providersFile` in `angular.json`, and `ng test` gives it to every spec, `render()` and `TestBed` alike:

```typescript title="src/test-providers.ts"
import { heartIcon, provideIcons } from './components/ui/icon';

export default [provideIcons({ heartIcon })];
```

### From a copy that had every icon

Icon copies before `provideIcons()` came with every icon, so an app drew any of them without registering it. The `dolan update` that brings the new copy registers the icons your app names for you:

- **It looks for icon names in your `.ts` and `.html` files,** outside the components' own folders: in `name` and `icon` attributes (`name="check"`), and in `[name]` and `[icon]` bindings (`[name]="done() ? 'check' : 'x'"`).
- **A binding that reads data counts every icon name in your source.** With `[icon]="item.icon"`, or `on() ? 'check' : item.icon`, the names are in your data (`{ icon: 'home' }`), so every quoted string that's an icon's name counts. A string that only happens to be one, such as `'x'` for an axis, registers an icon you don't draw, which costs a few hundred bytes.
- **It adds `provideIcons()` with them to the `providers` of your `ApplicationConfig`,** in `app.config.ts`, and says which it registered. Without an `ApplicationConfig`, it prints the call to add.
- **It does this once.** An app that calls `provideIcons()` or `provideAllIcons()` outside its specs is left alone.
- **A name built at runtime can't be found,** such as `'arrow-' + side`. Drawing it throws the error above, naming the icon to register.
- **`ICONS` is gone.** `update` lists your files that read it. For an icon's markup, use `iconSvg(chevronRightIcon)`.

### Colors

Without `color`, an icon draws in your theme's foreground, like the text next to it. Pass `color` a theme token or a literal color:

```angular-html
<ui-icon name="trash" color="var(--destructive)" />
<ui-icon name="heart" color="#ef4444" />
```

- **Theme tokens are looked up in TypeScript.** Lynx's `<svg>` element can't read CSS, so `icon-theme.ts`, copied next to the icon, keeps the theme's colors. If you change a color in `default.css` or `dark.css`, pass the new value to `provideIconTheme()` too (see below). Text color classes such as `text-primary` have no effect on an icon.
- **Some containers color the icons inside them.** A destructive [nav drawer item](/dolan/nav-drawer.md) draws its icons in `--destructive`. The icon's own `color` still wins.

### Dark mode

Icons follow the app's appearance: light colors in light mode, dark colors in dark mode, as the [theme](/dolan/theming.md#dark-mode) does. There's nothing to set up.

To change the colors, or where the scheme comes from, use `provideIconTheme()`:

```typescript title="src/app/app.config.ts"
import { provideIconTheme } from '../components/ui/icon/icon-theme';

export const appConfig: ApplicationConfig = {
  providers: [
    // ...
    provideIconTheme({
      light: { primary: 'rgba(37, 99, 235, 1)' },
      dark: { primary: 'rgba(96, 165, 250, 1)' },
    }),
  ],
};
```

- **`light` and `dark`** take token values to override, if you changed your theme's colors.
- **`colorScheme`** is `'system'` by default: the appearance the app is drawn in, [`LynxTheme.appearance`](/api/angular-lynx/device/theme.md). `'light'` or `'dark'` keeps to one table, and a function such as `() => (settings.dark() ? 'dark' : 'light')` follows a theme class of your own.

The same setting colors [Spinner](/dolan/spinner.md), [Pagination](/dolan/pagination.md)'s arrows and a loading [Button](/dolan/button.md)'s spinner, and picks [Glass](/dolan/glass.md)'s light or dark material. Charts have their own, [`provideChartTheme()`](/dolan/chart.md).

### Your own SVG

For a mark the set doesn't have, such as a sign-in provider's, pass its markup to `svg` instead of `name`:

```typescript title="src/app/sign-in.ts"
import { Component } from '@angular/core';
import { UiButton } from '../components/ui/button';
import { UiIcon } from '../components/ui/icon';

@Component({
  selector: 'app-sign-in',
  imports: [UiButton, UiIcon],
  template: `
    <ui-button variant="outline">
      <ui-icon [svg]="githubMark" />
      Continue with GitHub
    </ui-button>
  `,
})
export class SignIn {
  // GitHub's mark (its path shortened here), filled with currentColor.
  readonly githubMark = `<svg viewBox="0 0 16 16"><path fill="currentColor" d="…"/></svg>`;
}
```

- **`currentColor` takes the icon's color,** as the set's icons do: `color`, a button's label color, or the theme's foreground. A one-color mark written in `currentColor` follows your theme, and dark mode as set above.
- **Colors written out stay,** so a multi-color mark, such as Google's, keeps them.
- **`xmlns` is optional.** The icon adds it to the root `<svg>`: without it, the web preview draws nothing.
- **Draw lines with `<path>`.** The [`<svg>` element](/api/elements/svg.md) has the same limits here: no `<line>` on iOS and Android, and no CSS.
- **Components that show an icon take one too:** `[svg]` in place of `icon`, drawn in their own row, at their size and in their color for their state. That's the items of a [Tab Bar](/dolan/tab-bar.md#your-own-mark), a [Dock](/dolan/dock.md#your-own-mark), a [Menu](/dolan/menu.md#items) and a [Toolbar](/dolan/toolbar.md#your-own-icon), and an [Empty State](/dolan/empty-state.md). Pass it to them rather than putting a `<ui-icon>` beside them.
- **Give an icon `name` or `svg`, not both.** With neither or both, it throws an error.

The example at the top of this page draws Google's and GitHub's marks, and [Button](/dolan/button.md)'s example puts them in sign-in buttons.

### Sizes

```angular-html
<ui-icon name="heart" size="xs" />
<ui-icon name="heart" size="sm" />
<ui-icon name="heart" size="md" />
<ui-icon name="heart" size="lg" />
```

The sizes are 16, 20, 24 and 32 pixels square. Without a `size`, an icon is 24px, or the size its container gives it: an icon in a [Button](/dolan/button.md) or a [Button Group](/dolan/button-group.md) fits the button's size.

### Type-safe names

`IconName` is the union of every icon name in the set, registered or not. It's a type, so it adds nothing to your app's scripts.

```typescript
import { signal } from '@angular/core';
import { type IconName } from '../components/ui/icon';

const current = signal<IconName>('check');
```

For an icon's markup, as a string to pass to `svg` or an `<svg>` element's `content`, `iconSvg(checkIcon)` puts the icon's body in its root `<svg>`.

### Spacing

`class` takes Tailwind classes for the icon, such as `class="mr-2"`.

### Available icons

Each is the export of its name in camel case with `Icon` on the end: `alert-triangle` is `alertTriangleIcon`, and `undo-2` is `undo2Icon`.

**Common:** `check`, `x`, `plus`, `minus`, `chevron-down`, `chevron-up`, `chevron-left`, `chevron-right`, `arrow-left`, `arrow-right`, `search`, `menu`, `info`, `alert-triangle`, `loader`, `circle`, `ellipsis`, `eye`, `eye-off`, `settings`, `trash`, `heart`, `star`, `bell`

**Navigation and arrows:** `arrow-up`, `arrow-down`, `arrow-up-right`, `arrow-up-left`, `arrow-down-right`, `arrow-down-left`, `chevrons-up`, `chevrons-down`, `chevrons-left`, `chevrons-right`, `move`, `maximize`, `minimize`, `external-link`, `refresh-cw`, `rotate-cw`, `undo-2`, `redo-2`

**Actions and editing:** `edit`, `pencil`, `copy`, `clipboard`, `save`, `download`, `upload`, `share-2`, `sliders-horizontal`, `zoom-in`, `zoom-out`, `scissors`, `trash-2`, `pin`, `link`, `filter`

**Media:** `play`, `pause`, `square`, `circle-stop`, `skip-forward`, `skip-back`, `rewind`, `fast-forward`, `volume-2`, `volume-x`, `mic`, `mic-off`, `camera`, `video`, `music`, `headphones`

**Communication:** `mail`, `message-circle`, `message-square`, `send`, `phone`, `phone-call`, `at-sign`, `inbox`, `megaphone`, `rss`, `reply`, `globe`

**Files and folders:** `file`, `file-text`, `file-plus`, `folder`, `folder-open`, `book`, `book-open`, `archive`, `paperclip`, `newspaper`, `database`, `hard-drive`

**Status:** `check-circle`, `x-circle`, `alert-circle`, `plus-circle`, `minus-circle`, `shield`, `shield-check`, `lock`, `lock-open`, `key`, `ban`, `help-circle`

**People:** `user`, `users`, `user-circle`, `user-plus`, `user-check`, `user-x`, `thumbs-up`, `thumbs-down`, `smile`, `frown`, `hand`, `handshake`

**Commerce:** `shopping-cart`, `shopping-bag`, `credit-card`, `dollar-sign`, `tag`, `tags`, `gift`, `package`, `truck`, `wallet`, `receipt`, `store`

**Weather and nature:** `sun`, `moon`, `cloud`, `cloud-rain`, `cloud-snow`, `wind`, `droplet`, `zap`, `snowflake`, `flame`, `sunrise`, `sparkles`

**Places and devices:** `home`, `calendar`, `clock`, `map-pin`, `map`, `compass`, `wifi`, `bluetooth`, `battery`, `smartphone`, `monitor`, `laptop`, `server`, `cpu`, `keyboard`, `power`

**Layout and text:** `layout-grid`, `layout-dashboard`, `table`, `columns-3`, `rows-3`, `list`, `list-checks`, `list-ordered`, `bold`, `quote`, `align-left`, `align-center`, `align-right`, `type`

**Charts:** `chart-bar`, `chart-line`, `chart-pie`, `chart-column`, `activity`, `trending-up`, `trending-down`, `target`

**Objects:** `award`, `trophy`, `crown`, `rocket`, `lightbulb`, `coffee`, `terminal`, `code`, `command`, `git-branch`, `bug`

## API

### UiIcon

| Input   | Type                           | Default     | Description                                                                                                                                                 |
| ------- | ------------------------------ | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `name`  | `IconName \| undefined`        | `undefined` | An icon from the set. Give this or `svg`.                                                                                                                   |
| `svg`   | `string \| undefined`          | `undefined` | SVG markup to draw instead, such as a sign-in provider's mark. Give this or `name`.                                                                         |
| `size`  | `'xs' \| 'sm' \| 'md' \| 'lg'` | `'md'`      | 16, 20, 24 or 32 pixels square.                                                                                                                             |
| `color` | `string \| undefined`          | `undefined` | The color of the set's strokes and of `currentColor` in `svg`: a theme token such as `var(--primary)`, or a literal color. The theme's foreground if unset. |
| `class` | `string`                       | `''`        | Extra Tailwind classes for the icon.                                                                                                                        |

No outputs.

### Functions

| Function              | Returns    | Description                                                                                                                                          |
| --------------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| `provideIcons(icons)` | `Provider` | Registers the icons in `icons`, an object of the set's exports such as `{ checkIcon, heartIcon }`, for an app's config or a component's `providers`. |
| `provideAllIcons()`   | `Provider` | Registers every icon in the set, and puts them all in the app's scripts.                                                                             |
| `iconSvg(icon)`       | `string`   | An icon's markup: its body in the set's root `<svg>`, stroked in `currentColor`.                                                                     |

## Related

- [`<svg>`](/api/elements/svg.md): the element that draws the icons
- [Empty State](/dolan/empty-state.md): shows an icon above a message
- [Theming](/dolan/theming.md): the colors to match
- [Dark mode](/guide/dark-mode.md): switching the theme with the phone
