Skip to content
GitHub11 stars

Pick the icon set your components draw their icons from. add installs its package.

The components draw their icons with the Icon component, from the package of an icon set. You pick the set the way shadcn/ui's iconLibrary does: add installs that set's package and copies each component with the set's icons, as <Icon Data="…" /> elements. For icons of your own, each set is also a NuGet package.

Icon libraries

LibraryiconLibraryPackageIcons' license
Lucide lucide Blazix.Icons.Lucide ISC
Tabler Icons tabler Blazix.Icons.Tabler MIT
Hugeicons hugeicons Blazix.Icons.Hugeicons MIT (the free set)
Phosphor Icons phosphor Blazix.Icons.Phosphor MIT
Remix Icon remixicon Blazix.Icons.Remixicon Apache-2.0 (4.8.0)
Font Awesome Free fontawesome Blazix.Icons.FontAwesome CC BY 4.0

Lucide is the default, and the one these docs show. The components use the same icons in each set as shadcn/ui does. Font Awesome, which shadcn/ui doesn't offer, uses its free solid icons.

Choosing a library

Pass --icon-library to init. It sets iconLibrary in blazix.json, which you can also edit by hand, and installs that set's package.

dnx Blazix.Cli init --icon-library tabler

From then on, add copies each component with that set's icons, and installs the package if the project doesn't have it yet. Each icon keeps the classes and attributes the component gives it, so it sizes and colors the same way in every set. In the Accordion's trigger, the copy has:

Components/UI/Accordion/AccordionTrigger.razor
<Icon Data="TablerIcons.ChevronDown"
      aria-hidden="true" data-slot="accordion-trigger-icon" class="pointer-events-none shrink-0 group-aria-expanded/accordion-trigger:hidden" />

add takes no --icon-library of its own. It uses the library in blazix.json and refuses a different one, so a project never mixes sets by accident.

Changing library

For components you've already added, run migrate icons. It asks which libraries to migrate from and to, unless you pass --from and --to, then asks you to confirm. Once you do, it moves their icons, installs the new library's package, and sets iconLibrary, so later adds match.

dnx Blazix.Cli migrate icons --to phosphor

Options

Usage: blazix migrate icons [path] [options]

Arguments:
  path                   a file or folder to migrate (default: componentsDir)

Options:
  --from <library>       the library the icons come from (default: blazix.json's iconLibrary)
  --to <library>         the library to migrate to, which must differ from --from: lucide, tabler, hugeicons, phosphor, remixicon, fontawesome
  -y, --yes              migrate without the confirmation
  -p, --project <path>   the project, when the folder has more than one

With a path, it migrates just those files and leaves blazix.json alone. Each icon with no equivalent in the new library is listed by name and left as it is. The CLI pairs the icons its components use, so an icon of your own that no component uses has no equivalent here, even where the new library has one. Migrate those by hand, or keep them.

Components copied by an earlier version draw their icons inline, as SVG. migrate icons moves only <Icon>s, so those copies stay as they are. To get the icon component instead, add the component again with --overwrite: the copy is replaced with the current one, which uses <Icon>s from your library.

Icons of your own

Each set is a package of its own. Add the one that matches your components, or any other:

dotnet add package Blazix.Icons.Lucide

Then render an icon with <Icon>, from Blazix.Icons, which the set's package brings with it. Put the two @using lines in _Imports.razor to use icons everywhere, as the examples in these docs do:

Pages/Files.razor
@using Blazix.Icons
@using Blazix.Icons.Lucide

<Button>
    <Icon Data="LucideIcons.Plus" />
    New file
</Button>

<Button Variant="ButtonVariant.Outline" Size="ButtonSize.Icon">
    <Icon Data="LucideIcons.Settings" Label="Settings" />
</Button>
  • Without Label, an icon is decoration and is hidden from assistive technology (aria-hidden="true"). Use it next to text that says the same thing.
  • With Label, it's an image with that name (role="img" and aria-label). Give one to an icon that's the only content of a button or link, so the control has a name.
  • It takes the text color (currentColor). Attributes you pass, such as class, style and width, go on the <svg> and win over its defaults. StrokeWidth changes an outline icon's stroke, which defaults to 2.
  • Each icon is a property, so a typo is a compile error, and your editor completes the names. Trimming, which Blazor WebAssembly does when you publish, keeps only the icons your app uses: an app that uses two Lucide icons ships a few kilobytes of icon data, not the whole set.
  • An icon that points along the line, such as an arrow or a chevron, should turn around in right-to-left layouts. Add rtl:rotate-180 to its classes. The components' own icons do this already (see RTL).

Licenses

Blazix's code is MIT. The icons keep their own licenses, listed above. Each package carries its set's license as ICONS-LICENSE.txt. Lucide's icons are ISC, except the ones it took from Feather, which are MIT.

  • Font Awesome Free: its icons are CC BY 4.0, which requires attribution. Each package carries the attribution in ICONS-LICENSE.txt, and so do the CLI's notices. The components name the package's icons and carry no SVG of their own.
  • Remix Icon: the package and the components use Remix Icon 4.8.0, its last release under Apache-2.0. From 4.9.0 Remix Icon has a license of its own, the Remix Icon License v1.0. That license doesn't allow distributing the icons as an icon library, which the package would be. Icons that Remix Icon added after 4.8.0 aren't included.