Skip to content

Components

Astro Iconset’s main API is Icon, which renders optimized SVG markup in your HTML.

Import from astro-iconset/components and use it like any Astro component:

---
import { Icon } from "astro-iconset/components";
---
<Icon name="logo" />

Rendering happens on the server; there is no client-side icon runtime.

You can pass name or icon, plus standard SVG attributes (including ARIA).

PropTypeDescription
namestringLocal slug (for example logo or logos/astro) or Iconify id (mdi:account)
iconAstroIconImportData from import x from "*.svg?icon" — mutually exclusive with name
titlestringAdds a <title> for accessibility
descstringAdds a <desc> when needed
sizenumber | stringShorthand for width and height
width / heightnumber | stringExplicit dimensions
is:inlinebooleanWhen true, inlines the SVG without the sprite <symbol> path
interface Props extends HTMLAttributes<"svg"> {
name?: string;
icon?: AstroIconImport;
"is:inline"?: boolean;
title?: string;
desc?: string;
size?: number | string;
width?: number | string;
height?: number | string;
}

Use name or icon, not both.

By default, the first use of an icon on a page can emit a <symbol> and later uses reference it with <use>, which keeps HTML smaller when the same icon repeats.

Set is:inline when you want full inline SVG without that sprite behavior (for example for a one-off or special cases).

---
import { Icon } from "astro-iconset/components";
---
<Icon name="mdi:account" size={32} title="Account" />
---
import { Icon } from "astro-iconset/components";
import mark from "../assets/mark.svg?icon";
---
<Icon icon={mark} title="Mark" />

You cannot import Astro’s Icon directly inside React/Vue/Svelte files. Either:

---
import ReactComponent from "./ReactComponent.jsx";
import { Icon } from "astro-iconset/components";
---
<ReactComponent>
<Icon name="logo" />
</ReactComponent>