Skip to content

[ESLint] Add a rule about wrapping EuiButtonIcon with EuiToolTip #9578

Closed

Description

@weronikaolejniczak

Problem

EuiButtonIcon requires an aria-label for accessibility and Kibana adoption is near-universal (98%). However, aria-label is only consumed by screen readers. Sighted users get no visible tooltip cue unless the button is explicitly wrapped with EuiToolTip.

As a workaround, 82 instances in Kibana (8%) set the HTML title attribute to surface a tooltip for sighted users. This is the wrong approach: browser-native tooltips are unstyled, have no delay control, no keyboard accessibility and are inconsistent with the EUI design system.

The correct pattern is to wrap EuiButtonIcon with EuiToolTip, using the button's label as the tooltip content:

<EuiToolTip content={label}>
  <EuiButtonIcon aria-label={label} iconType="pencil" />
</EuiToolTip>

Proposed rule

Add an ESLint rule that:

  • warns when EuiButtonIcon is not wrapped with EuiToolTip,
  • warns when title is set on EuiButtonIcon with a message directing consumers to use EuiToolTip instead.

The fix is auto-applicable:

  • wrap EuiButtonIcon with <EuiToolTip content={ariaLabel}> when aria-label is passed,
  • wrap EuiButtonIcon with <EuiToolTip content={title}> when title prop is used, remove the title prop and import EuiToolTip if not already present.

We should also proactively go and update these warnings in Kibana using LLM.

Scope

Rule location: packages/eslint-plugin/src/rules/
Target: <EuiButtonIcon />
Auto-fixable: yes

Activity

  1. mattkime commented on Jun 1, 2026

    @mattkime
    Contributor

    I'm curious - is there a reason why the tooltip hasn't been made internal to EuiButtonIcon?

  2. weronikaolejniczak commented on Jun 1, 2026

    @weronikaolejniczak
    ContributorAuthor

    @mattkime that's a good question! We're not wrapping the button internally because we want to keep it atomic and avoid interface bloat (extra tooltip props, conditional rendering) and avoid breaking the single-responsibility principle. Additionally, the aria-label isn't the same in all cases - most often it shouldn't be identical to the tooltip text - so coupling them (using whatever you pass as aria-label as the tooltip content) would lead to worse a11y. Finally, there are cases where we really don't want a visible tooltip at all. The idiomatic React approach here is composition. The tradeoff is ergonomics, but from EUI's perspective that's acceptable, which is also why we're handling the migration ourselves and added an ESLint rule to stand guard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions