---
title: "Icon"
description: "Icon component - Lucide icons sized and colored with CSS custom properties."
slug: "icon"
---

import { DocPage, PageHeader, SkillPanel, SourceFiles, SourceNote, StatesSection, CodeBlock, Demo, DemoCode, ChangelogEntries, ArchBody, StatsClaim, StatsCards, PageOverlay, DocText, DocLink, H2, SkillField, SkillText, SkillRow, SkillGrid, Variant, ApiPill, Dim, CodeCard, TableCard } from "../../lib/components/index";

<DocPage meta={meta}>

<PageHeader slug="icon" title="Icon" component="icon">
  ~1,500 <DocLink href="https://lucide.dev/icons/" target="_blank">Lucide</DocLink> icons via CDN. Write <code>&lt;i data-lucide="name"&gt;</code> - the Lucide CDN script replaces it with an inline SVG at page load. Requires the Lucide <code>&lt;script&gt;</code> tag (see <DocLink href="installation.html">Installation</DocLink>).
</PageHeader>

<SkillPanel component="icon">
  <SkillField label="Native basis">
<SkillText><code>&lt;i&gt;</code> element with <code>data-lucide</code> attribute. Icons are provided by the <DocLink href="https://lucide.dev" target="_blank">Lucide</DocLink> icon library via CDN. Lucide replaces each <code>&lt;i data-lucide="name"&gt;</code> with an inline SVG on page load.</SkillText>
  </SkillField>

  <SkillField label="Web Platform APIs">
<SkillRow>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/SVG/Element/svg" title="inline scalable vector graphics (injected by Lucide)"><code>&lt;svg&gt;</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-hidden" title="hides decorative icons from screen readers"><code>aria-hidden</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#currentcolor_keyword" title="icons inherit stroke color from the parent's color property"><code>currentColor</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion" title="suppresses icon animations when user prefers reduced motion"><code>prefers-reduced-motion</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/CSS/@media/forced-colors" title="maps icon color to system CanvasText in Windows High Contrast Mode"><code>forced-colors</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-contrast" title="increases stroke width when user requests more contrast"><code>prefers-contrast</code></ApiPill>
  </SkillRow>
  </SkillField>

  <SkillField label="Data attributes">
<SkillText dense>• <code>data-lucide</code> - icon name (required)</SkillText>
  <SkillText dense>• <code>data-size</code> - <code>xs</code> | <code>sm</code> | <code>md</code> | <code>lg</code> | <code>xl</code></SkillText>
  <SkillText>• <code>data-animate</code> - <code>spin</code></SkillText>
  </SkillField>

  <SkillField label="Notes">
<SkillText dense>• Icons inherit <code>currentColor</code> for stroke - they automatically match the parent's text color</SkillText>
  <SkillText dense>• Browse all available icons at <DocLink href="https://lucide.dev/icons/" target="_blank">lucide.dev/icons</DocLink></SkillText>
  <SkillText dense>• Lucide provides ~1,500 icons covering every common web app need</SkillText>
  <SkillText dense>• The CDN script replaces <code>&lt;i data-lucide="name"&gt;</code> elements with inline SVGs on page load</SkillText>
  <SkillText dense>• Use <code>stroke-width</code> attribute to adjust line thickness (default: <code>2</code>)</SkillText>
  <SkillText dense>• Prefer visually-hidden text (<code>.sr-only</code>) over <code>aria-label</code> for accessible standalone icons</SkillText>
  <SkillText dense>• Animations (e.g., <code>data-animate="spin"</code>) are suppressed when the user has <code>prefers-reduced-motion</code> enabled</SkillText>
  <p class="text-muted-foreground m-0">• <code>prefers-contrast: more</code> increases stroke width to 2.5 for better visibility</p>
  </SkillField>
</SkillPanel>

```html example label="Basic usage" hint="Use data-lucide with any icon name from lucide.dev/icons." previewStyle="gap:1.5rem;"
<i data-lucide="home"></i>
<i data-lucide="settings"></i>
<i data-lucide="user"></i>
<i data-lucide="search"></i>
```

```html example label="Sizes" hint="Use data-size to control icon size." previewStyle="gap:2rem;align-items:center;"
<i data-lucide="star" data-size="xs"></i>
<i data-lucide="star" data-size="sm"></i>
<i data-lucide="star"></i>
<i data-lucide="star" data-size="md"></i>
<i data-lucide="star" data-size="lg"></i>
<i data-lucide="star" data-size="xl"></i>
```

```html example label="With buttons" hint="Icons inside buttons inherit the button's color."
<button class="btn" data-variant="default">
  <i data-lucide="save"></i>
  Save
</button>

<button class="btn" data-variant="outline" data-size="icon" aria-label="Settings">
  <i data-lucide="settings"></i>
</button>
```

```html example label="Color" hint="Icons inherit currentColor. Change color with text color utilities." previewStyle="gap:1.5rem;"
<i data-lucide="circle-check" data-size="lg" style="color: oklch(0.72 0.19 142)"></i>
<i data-lucide="alert-triangle" data-size="lg" style="color: oklch(0.77 0.17 75)"></i>
<i data-lucide="x-circle" data-size="lg" style="color: var(--destructive)"></i>
<i data-lucide="info" data-size="lg" style="color: oklch(0.62 0.21 255)"></i>
```

```html example label="Stroke width" hint="Adjust line thickness with the stroke-width attribute. Default is 2." previewStyle="gap:2rem;align-items:center;"
<i data-lucide="heart" data-size="lg" stroke-width="1"></i>
<i data-lucide="heart" data-size="lg" stroke-width="1.5"></i>
<i data-lucide="heart" data-size="lg" stroke-width="2"></i>
<i data-lucide="heart" data-size="lg" stroke-width="3"></i>
```

```html example label="Accessible icon" hint="For standalone icons that convey meaning, use visually-hidden text or aria-label." previewStyle="gap:2rem;align-items:center;"
<span style="display: inline-flex; align-items: center">
  <i data-lucide="phone" data-size="md" aria-hidden="true"></i>
  <span class="sr-only">Phone number</span>
</span>

<i data-lucide="alert-triangle" data-size="md" aria-label="Warning" role="img"></i>
```

```html example label="Animated (spinner)" hint="Add data-animate='spin' for loading indicators. Animation is suppressed when the user has prefers-reduced-motion enabled." previewStyle="gap:2rem;align-items:center;"
<i data-lucide="loader-circle" data-size="md" data-animate="spin"></i>

<button class="btn" data-variant="outline" disabled>
  <i data-lucide="loader-circle" data-animate="spin"></i>
  Loading…
</button>
```

```html example label="Filled icons" hint="Use the fill and stroke-width attributes for filled icon variants. Works well with simple shapes." previewStyle="gap:1.5rem;align-items:center;"
<i data-lucide="star" data-size="lg" fill="currentColor" stroke-width="0"></i>
<i data-lucide="heart" data-size="lg" fill="currentColor" stroke-width="0"></i>

<!-- Filled with stroke outline -->
<i data-lucide="star" data-size="lg" fill="currentColor" stroke-width="1"></i>
```

<p class="text-sm font-medium mb-2 mt-6">Browse all icons</p>

<p class="text-xs text-muted-foreground mb-3">Lucide provides ~1,500 icons. Browse and search the full set at:</p>

<a href="https://lucide.dev/icons/" target="_blank" class="btn" data-variant="outline" style="text-decoration:none;"><i data-lucide="external-link" /> lucide.dev/icons </a>

<SourceFiles component="icon" section="css" />

</DocPage>
