The Icon component renders an iconoir icon inline. Icons inherit the surrounding
text colour via currentColor and default to 1em square so they line up with
the text they sit alongside.
---
import Icon from "astro-theme-university/components/Icon.astro";
---
<Icon name="github" />
Finding an icon name#
Use the pnpm icons script from the workspace root:
pnpm icons # list all ~1,700 names
pnpm icons github # filter by substring (case-insensitive)
Pass the bare name (no iconoir: prefix) to <Icon name="...">.
Props#
| Prop | Type | Default | Description |
|---|---|---|---|
name * | string | --- | iconoir icon name (e.g. "github"). The `iconoir:` iconify prefix is added internally. |
size | string | number | "1em" | CSS length for width and height. Bare numbers are treated as px. Defaults to "1em". |
class | string | --- | Class names applied to the rendered <svg>. |
style | string | --- | Inline style applied to the rendered <svg>. |
"aria-label" | string | --- | Accessible label. When set, the icon becomes a labelled `role="img"` instead of decorative. |
Examples#
Default size (1em --- matches surrounding text)
This sentence has an inline icon.
Custom size
Colour inherits from the parent
Error: something went wrong.
Labelled (role='img')
Accessibility#
By default, the icon renders with aria-hidden="true" and focusable="false"
— appropriate for decorative icons sitting next to a text label. Pass
aria-label to flip it to a labelled role="img" element when the icon is the
only thing conveying meaning (e.g. an icon-only button).
Using other iconify sets#
The theme ships iconoir only. Consumers needing a different iconify set can use
the IconifyIcon re-export, which is the underlying astro-icon <Icon>:
---
import { IconifyIcon } from "astro-theme-university/components/Icon.astro";
---
<IconifyIcon name="mdi:home" />
Add the corresponding @iconify-json/<set> package to your project’s
dependencies.