Skip to content
Elements Icon

Icon

Any Iconify icon by name (i-ph-house, mdi:home, a bare Lucide name), bundled into the app at build time, with the Lucide icons that components use built in.

On this page

Examples

Built-in icons

Razor
@* The Lucide icons are built into the library, by bare name or as i-lucide-{name} / lucide:{name}. An unknown name renders an empty icon marked data-kly-missing-icon. *@
<div class="flex flex-wrap items-center gap-4">
    @foreach (var name in new[] { "search", "bell", "mail", "calendar", "heart", "star", "download", "globe" })
    {
        <KlyIcon Name="@name" Size="KlySize.Lg" />
    }
    <KlyIcon Name="check" Size="KlySize.Xl" Label="Done" Class="text-(--klyroo-success-text)" />
</div>

Iconify collections

The build finds these names in the example's source, downloads them from the Iconify API and compiles them into the app. custom:klyroo comes from a folder of SVG files. See the Icons guide.

Razor
@* Any Iconify icon works by name: i-{collection}-{name} or {collection}:{name}. Names written as literals are found in this file
   when the project is built; the build downloads them from the Iconify API and compiles them into the app. *@
<div class="flex flex-wrap items-center gap-4" data-testid="icon-collections">
    <KlyIcon Name="ph:house" Size="KlySize.Xl" Label="Phosphor house" />
    <KlyIcon Name="i-mdi-home" Size="KlySize.Xl" Label="Material Design home" />
    <KlyIcon Name="i-mdi-light-home" Size="KlySize.Xl" Label="Material Design Light home" />
    <KlyIcon Name="simple-icons:github" Size="KlySize.Xl" Label="GitHub logo" />
    <KlyIcon Name="i-simple-icons-nuget" Size="KlySize.Xl" Label="NuGet logo" />
    <KlyIcon Name="i-lucide-lightbulb" Size="KlySize.Xl" Label="Lucide lightbulb" />
    <KlyIcon Name="custom:klyroo" Size="KlySize.Xl" Label="Icon from a folder of SVG files" />
</div>

Names built at runtime

The scan reads literals only: the icons such a name can produce are listed in KlyrooIcon items of the project file.

Razor
@* A name built at runtime cannot be found in the source. List the icons it can produce in a KlyrooIcon item of the project file:
   <KlyrooIcon Include="ph:cube;ph:cube-fill;ph:cube-bold" /> *@
<div class="flex flex-wrap items-center gap-4" data-testid="icon-dynamic">
    @foreach (var weight in new[] { "", "-fill", "-bold" })
    {
        <KlyIcon Name="@($"ph:cube{weight}")" Size="KlySize.Xl" Label="@($"Cube{weight}")" />
    }
</div>

API

KlyIcon

Inline SVG icon by name, from the built-in Lucide set, any Iconify collection bundled at build time, or icons you register.

Parameters

Name Type Default Description
Class string Classes added to the root element, merged last so they win over the theme.
Label string Accessible name. Without it the icon is decorative and hidden from assistive technology.
Name (required) string "" The icon, by name, in any supported form: i-lucide-search , lucide:search , ph:house , i-simple-icons-github , or a bare Lucide name ( search ). The Lucide icons components use are built in; every other Iconify icon written as a literal in the app's sources is bundled at build time, and icons added to KlyrooIconOptions or from a KlyrooIconCollection folder work too. An icon that is not found renders an empty icon marked data-kly-missing-icon .
Size KlySize KlySize.Md Size of the icon, from Xs to Xl . Values: Xs, Sm, Md, Lg, Xl.
Ui IconUi Per-instance class overrides of the slots of the icon, see IconUi . They are merged after the theme and the Class parameter wins on the root slot.

Ui slots

Ui takes a IconUi with one class string per slot, merged after the theme.

Slot Styles
Base Classes merged into the base slot of KlyIcon , after the theme and the app configuration.