Skip to content

[Epic] Improve icons #8860

Open
5 of 10 issues completed
Open

Description

@tkajtoch

✨ Summary

EuiIcon still causes user-perceivable rendering issues in Kibana (load fade-in → extra document layers). Invalid or removed glyph names fail silently at runtime (<img src>). Closing IconType is not the path: it is a consumer-wide type migration and does not fix tree-shaking, layers, or the class-component/cache debt.

Direction: ship tree-shakeable icon components in a separate package, migrate Kibana and Cloud UI onto them, then remove icons from @elastic/eui. Keep EuiIcon only as deprecated compat until that cutover. Unknown string names on the old API get an empty placeholder + console warning in the meantime.

❗ Problem or Opportunity

1. Fade-in loading creates extra document layers

First-load fade-in puts each EuiIcon on its own layer, which slows graphics (not React) re-renders — especially scrollable EuiDataGrid (e.g. Alerts). New icon components must not repeat this.

2. Not tree-shakeable / webpack-only Partial

icon_map.ts uses explicit () => import('./assets/foo'). Unused SVGs are code-split; Vite/Rollup/esbuild work (#5463, #7982, #7852).

String type still ships the full name map with every EuiIcon import. True tree-shaking needs imported components (same idea as @elastic/eui-illustrations).

3. Invalid glyph names fail silently

IconType is EuiIconType | string | ComponentType, so | string makes the union string. tsc does not catch typos or removed names. Runtime treats unknown strings as URLs → broken image. ESLint no-deprecated-icon-aliases is only warn and only known aliases.

Closing IconType (#9940, closed) was evaluated and not taken: ~700 Kibana type errors, TS2590 on button ExclusiveUnion, Cloud UI the same class of work. Plugin registries (euiIconType, iconClass) are runtime strings and would never fully type-check as a closed glyph union.

🎯 Value

  • DataGrid / Alerts: no extra layers on the new components.
  • Unused glyphs drop out of the bundle.
  • Missing names fail at import (and CI), not as broken <img>s.
  • Can evolve glyphs (e.g. adaptive color) without fighting EuiIcon.

Urgency

Broken leftover aliases in Kibana are already renamed. No rush to close IconType. Runtime empty+warn is the small immediate gap. The package + migration is the real initiative.

🧠 Feasibility & Direction

Do not rewrite EuiIcon in place (class component, cache, onIconLoad, string map). New package + new components; deprecate EuiIcon; migrate consumers; then delete icons from @elastic/eui.

Custom URLs / data URIs / SVG components stay on EuiIcon until those call sites have an explicit story (or stay as <img> / raw SVG). Glyph names move to imported components.

❓ Open Questions to answer

  • Package name: @elastic/eui-icons (#8909) vs @elastic/eui-glyphs (thread).
  • One <EuiGlyph type={Warning} /> wrapper vs dedicated <Warning /> components (or both).
  • Adaptive / CSS-variable glyphs (kibana#206540) — in scope for the new package, not for EuiIcon.
  • How long EuiIcon stays in @elastic/eui after #9980; what remains allowed (custom assets only vs full deprecation).

📐 Definition

Proposed Solution

  1. #9967 — EuiIcon: unknown glyph-shaped strings → empty placeholder + console.error/warn. Do not treat them as <img src>. Real asset URLs and components unchanged.
  2. #9979 — no-deprecated-icon-aliases → error; fix remaining hits.
  3. #8909 — @elastic/eui-icons: assets + generated components; deprecate EuiIcon in favor of imports.
  4. #9980 — Kibana + Cloud UI: codemods / ESLint / agent skills; migrate straightforward EuiIcon glyph usage; codeowners for the rest. Starts after EuiIcon is deprecated.
  5. #9981 — breaking: remove icon bundling from @elastic/eui once consumers are off it; communicate.

Later: escalate remaining string-glyph usage (console + ESLint) to errors so new EuiIcon glyph usage cannot land.

Out of scope / closed: #9940 closed IconType; #8910 onIconLoad, #8911 FC rewrite, #8912 cache — die with old EuiIcon, not rewritten in place.

Acceptance criteria

  • Unknown EuiIcon glyph names do not render the browser broken-image icon.
  • Icons are importable, tree-shakeable components from a dedicated package.
  • Kibana and Cloud UI have migrated straightforward glyph usage; remaining cases tracked with owners.
  • @elastic/eui no longer ships the icon map/assets (breaking, after migration).
  • Docs: import components, not string type, for glyphs.

Definition of done

Package published, consumers migrated (or explicitly excepted), icons removed from @elastic/eui, changelog + upgrade email/docs.

Documentation needs

Consuming-EUI + Icons docs: new imports, deprecation of string type / EuiIcon for glyphs, custom asset guidance, upgrade guide for #9981.

Impact scope

Breaking when icons leave @elastic/eui. Until then: additive package + deprecation. Kibana and Cloud UI are the migration surface (large, mechanical + some registries/custom renderers).

Rollout plan

EUI-only 9967 / 9979 → publish icons package + deprecate EuiIcon → Kibana/Cloud UI PRs per team → breaking removal. No closed-IconType EUI bump as the migration vehicle.

Goals

  1. Refactor EuiIcon to not rely on webpack magic strings Done
  2. Switch glyph usage from string type to imported components for tree-shaking and valid names in CI
  3. Prefer sync component imports; keep async only where needed
  4. New components must not use the load fade-in / extra layer

Sub-issues

Sub-issues

5 of 10 Issues completed
Loading 10 sub-issues

Activity

  1. changed the title [-][Meta] Refactor EuiIcon for performance and enhanced bundler support[/-] [+][Epic] Refactor EuiIcon for performance and enhanced bundler support[/+] on Jul 11, 2025
  2. self-assigned this
    on Jul 11, 2025
  3. tkajtoch commented on Jul 11, 2025

    @tkajtoch
    ContributorAuthor

    Prioritizing this as "should" on the next quarter roadmap due to the recently found performance bottleneck caused by icon load animations, which needs a refactor of the loading logic to get it fixed.

  4. added theissue type on Jul 17, 2025
  5. github-actions commented on May 11, 2026

    @github-actions

    👋 Hi there - this issue hasn't had any activity in 6 months. If the EUI team has not explicitly expressed that this is something on our roadmap, it's unlikely that we'll pick this issue up. We would sincerely appreciate a PR/community contribution if this is something that matters to you! If not, and there is no further activity on this issue for another 6 months (i.e. it's stale for over a year), the issue will be auto-closed.

  6. added
    stale-issue
    on May 11, 2026
  7. removed
    stale-issue
    on May 21, 2026
  8. 2 remaining items

  9. clintandrewhall commented on Aug 28, 2026

    @clintandrewhall
    Contributor

    @weronikaolejniczak We could consider naming the package @elastic/eui-glyphs, and a new EuiGlyph component, leaving EuiIcon in it's current state, (perhaps even deprecated, using EuiGlyph under the hood, etc). Then EuiIcon can continue to support base64, urls, etc, whereas EuiGlyph would purely for the glyphs we support. Then the rollout can be gradual, and enforced by a good eslint rule: "you're using a pre-defined glyph, EuiGlyph is more appropriate"). Would that help? Seems like it would.

  10. weronikaolejniczak commented on Aug 28, 2026

    @weronikaolejniczak
    Contributor

    @clintandrewhall yes, the best course of action IMHO is to not touch that EuiIcon and wrestle with Kibana and Cloud UI usage but deprecate and move towards a new solution. So EuiGlyph and eui-glyphs works perfectly 👍🏻 It's a similar idea to what I wrote above (imported SVG modules/dedicated icon components; we can even do both if we'd like, for those non-React usages).

  11. clintandrewhall commented on Aug 28, 2026

    @clintandrewhall
    Contributor

    Yeah, re-reading, I think I just restated your approach with component names. 😆 Glad to be aligned! Seems like a huge benefit with work we've done before. Would love to also explore the adaptive illustrations approach with the glyphs, if that's workable, now that we're closer to switching light/dark/high-contrast without refreshing the page.

  12. sphilipse commented on Aug 28, 2026

    @sphilipse
    Member

    I worry that leaving EuiIcon in place is going to mean we will ~never move off of it, because consumers are going to keep using it regardless of eslint warns, deprecated annotations etc. It's going to remain a pain in everyone's butt.

    Also from a consumer point of view, just typing a string is a much nicer experience than needing to import it explicitly from a package.

    If we do build a new package as a migration target, we should put in effort to:

    1. Migrate everyone off EuiIcon ASAP
    2. Try to block new EuiIcon usage

    Otherwise we have just created a second maintenance burden for ourselves without meaningfully improving the existing situation.

  13. changed the title [-][Epic] Refactor EuiIcon for performance and enhanced bundler support[/-] [+][Epic] Refactor EuiIcon for type-safety and performance[/+] on Aug 31, 2026
  14. weronikaolejniczak commented on Aug 31, 2026

    @weronikaolejniczak
    Contributor

    @sphilipse I understand the concern, thanks for sharing your thoughts 🙏🏻

    I would argue that separating this into a library does meaningfully improve the existing situation. Icons would be tree-shakeable, we would be able to modify them for e.g. adaptive color scheme just like we did with illustrations, we would reliably be able to tell consumers when icons don't exist without them being able to simply override types on their side, and we wouldn't drag behind the tech-debt that accumulated around icons (class component, cache registry, onIconLoad, slowing down performance).

    This way I'm proposing a meaningful refactor to icons as a whole, not only targeted fix for the string and calling it a day. Aligning EuiIcon to what I wrote above ☝🏻 would come with a lot of fighting the component and potential issues to be resolved on consumer side. Much more effort, both on EUI and Kibana/Cloud UI side, than starting anew and migrating off EuiIcon usage. Most cases we would be able to migrate with the initiative. The trickier cases like custom rendering we would raise with code-owners.

    That being said, I'm happy to continue #9940 but I want to say:

    • it will not be 2 days
    • and there's a lot to do on Kibana/Cloud UI side,
    • it does not fix all other issues that we currently have with icons.
  15. sphilipse commented on Aug 31, 2026

    @sphilipse
    Member

    After discussing synchronously, let's do this:

    1. Create the package with tree-shakeable components
    2. We migrate as much as possible to those tree-shakeable components
    3. Look into turning the console warn and ESLint warn into errors so we stop the bleeding more harshly
  16. changed the title [-][Epic] Refactor EuiIcon for type-safety and performance[/-] [+][Epic] Improve icons[/+] on Sep 1, 2026
  17. removed their assignment
    on Sep 21, 2026
  18. removed their assignment
    on Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions