Repository navigation
Description
Summary
EuiIcon public type / IconType is too wide to catch invalid or removed glyph names at compile time. After icon alias removals, leftover names render as broken <img>s (treated as asset URLs) instead of failing CI.
Currently, EuiIcon interface is loose. iconType accepts | string, effectively overwriting our string union of all acceptable iconType values. The goal is to tighten typing while keeping custom SVGs working.
Problem
Today:
export type EuiIconType = keyof typeof typeToPathMap; // already a string union
export type IconType = EuiIconType | string | ComponentType;EuiIconType | string effectively is string.
Custom assets is documented API (URL, data URI, React SVG element) and are widely used in Kibana and Cloud UI.
Options
| string has to be dropped no matter what.
// effectively `string`
type IconType = EuiIconType | string | ComponentType;
// instead:
type IconAssetUrl = `http://${string}` | `https://${string}` | `data:${string}` | `blob:${string}`;
type IconType = EuiIconType | IconAssetUrl | ComponentType;Two more things we can do.
String union (preferred)
Pros: smallest API change, tsc fails on unknown names
Cons: awkward one union member deprecation
UPDATE: removing icons will surface on EUI update PRs where we can handle it. No need for string enum.
String enum
Pros: allows @deprecated, tsc fails on unknown names
Cons: runtime object, bigger declaration file
Goal
- Named EUI glyphs are a closed type, so invalid / removed names error in a type-check
- Custom SVGs, URLs, data URIs and React components remain supported
- Prefer a path that can mark individual glyph names as
@deprecated(enum members, deprecated union aliases or equivalent) - Do not require migrating every Kibana/Cloud UI icon alongside with the EUI change if we can help it
Activity
eokoneyo commentedon Aug 24, 2026
Nice... we have an open issue in Kibana that relates to this, see elastic/kibana#184643
weronikaolejniczak commentedon Aug 24, 2026
@eokoneyo this issue is only partially fixing the one you mentioned.
Yes ✅ through
tscThis one I'd need some more context on. I'm wondering why
currentColorcustom SVG passed intypeis not working for some use cases?[EUI] Replace removed icon aliases with current glyph names (#286897)
[-][Icon] Tighten type interface[/-][+][EuiIcon] Tighten type interface[/+]weronikaolejniczak commentedon Aug 28, 2026
Dropping
| stringfor template-literal URLs is the right API butIconTypeis shared (EuiIcon.type, buttoniconType, tooltips, menus) and used by consumers. Kibana types icons asstringin many places. So you can't close it in one place and leave the rest asstring, that results in type errors.In EUI, closed
IconTypex buttonExclusiveUnionhits TS2590 and has to be fixed first.In Kibana, a packed build +
type_checkis ~700 errors / ~430 files.string-typed wrappers likeeuiIconType,iconClass,getIconType(): string, test dummies, SVG modules typed asstring. Those fields have to be comeIconType(or real glyph/URL values) and have cascading type errors.Valid names and custom SVGs/URLs still compile.
Cloud UI will be the same class of work.
tl;dr; this is not a one-line change, has broad impact and has to be given the appropriate time to tackle meaningfully, preferably starting with migrating on Kibana side. Not on a "Small (2-3d)" type of task (which it is on EUI side).
weronikaolejniczak commentedon Sep 1, 2026
We decided to do a meaningful solution by moving icon assets to a separate package with tree-shakeable icon components that we can easily deprecate. See #8909