Icons
Use the built-in Lucide icons, add the Tabler icons, and add your own
Using the built-in icons
AddStellarAdminUI() registers the Lucide icons, so you can use any Lucide icon in the <sa-icon> Tag Helper. Specify the icon's name in the name attribute:
<sa-icon name="plane"/>To find an icon's name, search the Lucide icons page. The name is displayed when you hover over an icon:

Names aren't case sensitive. When no icon has the name you specify, <sa-icon> renders a placeholder icon, so that you can see the mistake on the page.
<sa-icon> renders the icon as an inline <svg> element that uses currentColor, so the icon has the color and size of the text around it. See icon for how to change its size, color and stroke width.
Adding an icon pack
An icon pack is a set of icons that you register together. Besides the Lucide icons, StellarAdmin.UI includes the Tabler icons, in two icon packs: TablerOutlineIconPack for the outline icons and TablerFilledIconPack for the filled icons.
To register an icon pack, call AddIconPack<TIconPack>() in AddStellarAdminUI(). The example below registers the outline Tabler icons:
using StellarAdmin.UI.Icons;
builder.Services.AddStellarAdminUI(ui =>
{
ui.AddIconPack<TablerOutlineIconPack>();
});The icons in the pack replace any icons already registered with the same name, including the Lucide icons.
To find a Tabler icon's name, search the Tabler icons page. The name is displayed when you hover over an icon. To display only the outline or the filled icons, use the Style filter.

Keeping the names of an icon pack separate
To keep the icons of a pack from replacing icons with the same name, set a Prefix when you register the pack. The prefix is added to the start of each icon's name:
builder.Services.AddStellarAdminUI(ui =>
{
ui.AddIconPack<TablerOutlineIconPack>(pack =>
{
pack.Prefix = "tabler:";
});
});With the prefix in the example above, you use the Tabler plane icon as <sa-icon name="tabler:plane"/>, and <sa-icon name="plane"/> is still the Lucide icon.
Adding your own icons
To add an icon, call AddIcon() with the icon's name and an IconDefinition. The IconDefinition contains the attributes of the <svg> element, and the shapes that draw the icon, such as path, circle and rect elements. The example below adds a suitcase icon:
using StellarAdmin.UI.Icons;
builder.Services.AddStellarAdminUI(ui =>
{
ui.AddIcon("voyager-suitcase", new IconDefinition(
new Dictionary<string, string>
{
["xmlns"] = "http://www.w3.org/2000/svg",
["width"] = "24",
["height"] = "24",
["viewBox"] = "0 0 24 24",
["fill"] = "none",
["stroke"] = "currentColor",
["stroke-width"] = "2",
["stroke-linecap"] = "round",
["stroke-linejoin"] = "round",
},
[
new SvgShape("rect", new Dictionary<string, string>
{
["x"] = "3", ["y"] = "7", ["width"] = "18", ["height"] = "13", ["rx"] = "2",
}),
new SvgShape("path", new Dictionary<string, string>
{
["d"] = "M8 7V5a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",
}),
new SvgShape("path", new Dictionary<string, string> { ["d"] = "M8 7v13" }),
new SvgShape("path", new Dictionary<string, string> { ["d"] = "M16 7v13" }),
]));
});You then use the icon by its name:
<sa-icon name="voyager-suitcase"/>An icon replaces any icon already registered with the same name, including a Lucide icon.
To make an icon easier to find in an icon picker, pass its keywords as the third argument of the IconDefinition constructor, such as ["luggage", "baggage", "travel"]. The icon picker's search matches the keywords as well as the name. The Lucide and Tabler icons include the keywords of their projects.
Creating your own icon pack
To add more than a few icons, create an icon pack. An icon pack is a class that implements IIconPack and has a parameterless constructor. Its GetIcons() method returns the icons, by name, and its GetSemanticIconMappings() method returns the semantic icons it supplies.
The example below defines an icon pack with two icons:
using StellarAdmin.UI.Icons;
public class VoyagerIconPack : IIconPack
{
private static readonly Dictionary<string, string> SvgAttributes = new()
{
["xmlns"] = "http://www.w3.org/2000/svg",
["width"] = "24",
["height"] = "24",
["viewBox"] = "0 0 24 24",
["fill"] = "none",
["stroke"] = "currentColor",
["stroke-width"] = "2",
["stroke-linecap"] = "round",
["stroke-linejoin"] = "round",
};
public IReadOnlyDictionary<string, IconDefinition> GetIcons()
{
return new Dictionary<string, IconDefinition>
{
["voyager-suitcase"] = new IconDefinition(SvgAttributes,
[
Shape("rect", ("x", "3"), ("y", "7"), ("width", "18"), ("height", "13"), ("rx", "2")),
Shape("path", ("d", "M8 7V5a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2")),
Shape("path", ("d", "M8 7v13")),
Shape("path", ("d", "M16 7v13")),
]),
["voyager-compass"] = new IconDefinition(SvgAttributes,
[
Shape("circle", ("cx", "12"), ("cy", "12"), ("r", "9")),
Shape("path", ("d", "m15.5 8.5-2 5-5 2 2-5z")),
Shape("path", ("d", "M12 3v2")),
Shape("path", ("d", "M12 19v2")),
Shape("path", ("d", "M3 12h2")),
Shape("path", ("d", "M19 12h2")),
]),
};
}
public IReadOnlyDictionary<SemanticIconRole, string> GetSemanticIconMappings()
{
return new Dictionary<SemanticIconRole, string>();
}
private static SvgShape Shape(string name, params (string Name, string Value)[] attributes)
{
return new SvgShape(name, attributes.ToDictionary(a => a.Name, a => a.Value));
}
}To use the icon pack, register it with AddIconPack<TIconPack>():
builder.Services.AddStellarAdminUI(ui =>
{
ui.AddIconPack<VoyagerIconPack>();
});The example below uses the two icons from the pack:
<sa-icon name="voyager-suitcase"/>
<sa-icon name="voyager-compass"/>
<sa-icon name="plane"/>Changing the icons the components use
Some Tag Helpers render icons of their own. For example, <sa-pagination-ellipsis> renders an ellipsis icon. Instead of an icon name, these Tag Helpers use a semantic icon, an icon that an icon pack maps to a role, such as SemanticIconRole.PaginationEllipsis.
The icon packs map icons to the roles, and when you register an icon pack, its mappings replace the mappings of the icon packs registered before it. To keep the existing mappings, set ImportSemanticMappings to false when you register the pack:
builder.Services.AddStellarAdminUI(ui =>
{
ui.AddIconPack<VoyagerIconPack>(pack =>
{
pack.ImportSemanticMappings = false;
});
});Mapping icons in your own icon pack
To map the icons of your own icon pack to roles, return the mappings from its GetSemanticIconMappings() method:
public IReadOnlyDictionary<SemanticIconRole, string> GetSemanticIconMappings()
{
return new Dictionary<SemanticIconRole, string>
{
[SemanticIconRole.PaginationEllipsis] = "voyager-dots",
[SemanticIconRole.DropdownIndicator] = "voyager-caret-down",
};
}Each icon you map must be one of the icons the same pack's GetIcons() returns, even if an icon with that name is already registered. When it isn't, StellarAdmin.UI skips the mapping, and logs a warning when the app starts.
Changing the icon of a single role
To change the icon of a single role, call MapSemanticIcon() on the IconOptions, with the name of a registered icon:
builder.Services.Configure<IconOptions>(icons =>
{
icons.MapSemanticIcon(SemanticIconRole.PaginationEllipsis, "ellipsis-vertical");
});When no icon is registered with the name, StellarAdmin.UI keeps the role's previous icon, and logs a warning when the app starts.
Removing the Lucide icons
To use only your own icons, call ClearIcons() before you register your icon pack. ClearIcons() removes all the icons and mappings registered before it, including the Lucide icons.
builder.Services.AddStellarAdminUI(ui =>
{
ui.ClearIcons();
ui.AddIconPack<VoyagerIconPack>();
});ClearIcons() also removes the semantic icon mappings. When no icon is mapped to a role, the Tag Helpers that use the role render the placeholder icon. Map your own icons to the roles, or register another icon pack that maps them.
API Reference
AddIcon(name, iconDefinition)
Registers an icon. The icon replaces any icon already registered with the same name. Names aren't case sensitive.
AddIconPack<TIconPack>()
Creates an instance of TIconPack, and registers its icons and semantic icon mappings. TIconPack must have a parameterless constructor. The icons replace any icons already registered with the same name.
AddIconPack<TIconPack>(configure)
Registers an icon pack, like AddIconPack<TIconPack>(), with the options you set in configure:
Prop
Type
ClearIcons()
Removes all the icons and semantic icon mappings registered before it, including the Lucide icons.
IIconPack
Prop
Type
IconDefinition
Prop
Type
SvgShape
Prop
Type