Skip to content

[EuiListItemLayout] Add internal, shared list item component - #9530

Merged
mgadewoll merged 17 commits into
elastic:feat/selectable-ui-enhancementsfrom
mgadewoll:feat/548-list-item-layout
Apr 1, 2026
Merged

mgadewoll merged 17 commits into
elastic:feat/selectable-ui-enhancementsfrom
mgadewoll:feat/548-list-item-layout

Conversation

@mgadewoll

@mgadewoll mgadewoll commented Mar 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Important

This PR merges into a feature branch

closes https://github.com/elastic/eui-private/issues/548

This PR introduces a new internal component: EuiListItemLayout.

This component is an internal component only. It is not meant to be exported from EUI.

This component will be used across different EUI selection/list components, replacing the custom item implementations and creating a shared source of truth for behavior and styles.

Note

This work is part of the ongoing initiative to implement selection list UI enhancements (https://github.com/elastic/platform-ux-team/issues/1050)
There will be 5 more PRs after this one that will implement EuiListItemLayout into the following components: EuiSelectable, EuiComboBox, EuiListGroup, EuiContextMenu and EuiSuperSelect

Component behaviors

EuiListItemLayout controls styles, layout and semantic output for list items. It handles different variants to support different component implementations.

  • element: renders as li, div, button or a
  • checked
    • values: undefined, on, off (excluded) or mixed (indeterminate)
    • controls the visual checked indicator
    • applies the semantic aria-checked attribute IF the element role supports it
  • isSelected
    • controls the visual selected style (blue background and color)
    • applies the selected style only for single-selection or when showIndicator=false
    • controls the aria-selected and aria-current value when applicable
  • isSingleSelection: defines multi- vs single-selection
    • single-selection:
      • renders EuiIcon as checked state indicator
      • isSelected applies a visual selected state (blue background and color)
      • semantic selection:
        • no role OR non-checkable, non-selectable role -> aria-current
        • checkable role -> aria-checked
        • non-checkable, selectable role -> aria-selected
    • multi-selection:
      • renders EuiCheckboxControl as checked state indicator
      • isSelected does not apply a visual selected style
      • semantic selection:
        • no role OR non-checkable, non-selectable role -> aria-current
        • checkable role -> aria-checked
        • non-checkable, selectable role -> aria-selected
  • selectionMode: handled by default internally, but provides means to select between aria-checked and aria-selected manually when a supported checkable/selectable role is passed
  • isFocused: applies a "faux" focus style (matches the hover style, not regular focus style), that is used for indicating the actively navigated item in a listbox
  • extraAction
    • when passed with an interactive element (e.g. element=button) it will render as sibling to the main interactive element to ensure valid HTML. This case requires an additional outer wrapper to be rendered (.euiListItemLayout__wrapper).
      • all main props always go to the "main" element, which is the elment corresponding to the element value.

API Changes

component / parent prop / child change description
EuiListItemLayout element new Determines the rendered element. Accepted values: 'li' (default), 'div', 'button', 'a'. When element='a' and isDisabled=true, falls back to rendering a 'button'.
EuiListItemLayout children new Main label/content rendered inside the text slot.
EuiListItemLayout prepend new Slot for content rendered before the label (e.g. icons).
EuiListItemLayout append new Slot for non-interactive content rendered after the label (e.g. badges). Use extraAction for interactive appended elements.
EuiListItemLayout extraAction new Slot for an additional interactive action. When combined with element='button' or element='a', a wrapper element is rendered to avoid nesting interactive elements.
EuiListItemLayout wrapperElement new Sets the wrapper element for interactive components ('li' or 'div'). Has no effect when element='li' or element='div'. Defaults to 'li' when extraAction is present.
EuiListItemLayout wrapperProps new Props (className, css, style, etc.) applied to the wrapper element. Only applies when a wrapper is rendered (i.e. wrapperElement is set or extraAction is passed).
EuiListItemLayout contentProps new Props applied to the inner content wrapper <span>.
EuiListItemLayout textProps new Props applied to the label text <span>.
EuiListItemLayout prependProps new Props applied to the prepend <span> wrapper.
EuiListItemLayout appendProps new Props applied to the append <span> wrapper.
EuiListItemLayout tooltipProps new Passes props to an EuiToolTip wrapping the item. Tooltip is suppressed when isDisabled=true. For li/div components the tooltip wraps the inner content; for button/a it wraps the element itself.
EuiListItemLayout checked new Controls the visual checked indicator and (when a matching role is set) the aria-checked attribute. Accepted values: 'on', 'off', 'mixed', undefined.
EuiListItemLayout isSelected new Marks the item as selected. Applies aria-selected, aria-current, or aria-checked depending on element, role, and selectionMode. Also applies a visual selected style when isSingleSelection=true or showIndicator=false.
EuiListItemLayout isFocused new Styles the item as the currently keyboard-navigated item (pseudo-focus) without actually focusing it. Also programmatically shows/hides the tooltip when tooltipProps is set.
EuiListItemLayout isDisabled new Applies a visual disabled style and semantic disabled state (disabled attribute for button, aria-disabled for all other components). Suppresses the tooltip.
EuiListItemLayout isSingleSelection new Toggles between multi-selection (checkbox indicators, aria-checked) and single-selection (icon indicators, aria-selected/aria-current). Defaults to true.
EuiListItemLayout selectionMode new Manually overrides whether aria-checked or aria-selected is applied. Applies only when a supported checkable/selectable role is passed.
EuiListItemLayout showIndicator new Controls visibility of the selection indicator (checkbox or icon). Defaults to true.
EuiListItemLayout role new Native role attribute. Drives which ARIA selection attribute is applied. When using a custom role that natively supports checked states, set selectionMode='checked'.
EuiListItemLayout textWrap new Controls label text overflow behaviour. 'truncate' (default) clips with an ellipsis; 'wrap' allows line breaks.
EuiListItemLayout href new Anchor href. Only applied when element='a' and isDisabled=false.
EuiListItemLayout target new Anchor target. Only applied when element='a' and isDisabled=false.
EuiListItemLayout rel new Anchor rel. Only applied when element='a' and isDisabled=false.
EuiListItemLayout data-test-subj new Custom test subject. Defaults to 'euiListItemLayout'. When a wrapper is rendered, the wrapper receives '<value>-wrapper' and the inner element retains '<value>'.
EuiListItemLayout className / css / style new Standard CommonProps. Applied to the inner element (or to the wrapper when a wrapper is rendered).

Screenshots

Variant After
element="li" Screenshot 2026-03-26 at 17 07 48
element="div" Screenshot 2026-03-26 at 17 07 54
element="button" Screenshot 2026-03-26 at 17 08 00
element="a" Screenshot 2026-03-26 at 17 08 05
tooltip (hover) Screenshot 2026-03-25 at 10 11 32
tooltip (keyboard focus) Screenshot 2026-03-25 at 10 11 39
extraAction sibling DOM order
Screen.Recording.2026-03-25.at.10.14.25.mov

Impact Assessment

  • 🔴 Breaking changes — What will break? How many usages in Kibana/Cloud UI are impacted?
  • 💅 Visual changes — May impact style overrides; could require visual testing. Explain and estimate impact.
  • 🧪 Test impact — May break functional or snapshot tests (e.g., HTML structure, class names, default values).
  • 🔧 Hard to integrate — If integration is complex, stage commits in Kibana/Cloud UI branches for cherry-picking and link to them below.

Impact level: 🟢 None (new, internal component)

Release Readiness

  • Documentation: {link to docs page(s)} (internal component)
  • Figma: Ideation specs
  • Migration guide: {steps or link, for breaking/visual changes or deprecations}
  • Adoption plan (new features): {link to issue/doc or outline who will integrate this and where}

QA instructions for reviewer

Links

Checks

  • verify EuiListItemLayout matches design specs (ideation specs, review updates)
  • verify the component props and behavior work as expected
    • element renders different elements
    • isSingleSelection controls checked indicator render (EuiCheckboxControl vs EuiIcon)
    • showIndicator shows/hides the checked state indicator
    • isSelected applies a selected style only when isSingleSelection=false
    • isSelected controls the value of aria-current when isSingleSelection (when no role is set or a non-checkable, non-selectable role is set, e.g. "presentation")
    • isSelected controls the value of aria-selected when isSingleSelection (ensure a selectable role is set, e.g. "option")
    • checked controls the checked state indicator variant (checked, unchecked, mixed, excluded)
    • checked sets aria-checked correctly (when a checkable role is defined, e.g. "option" when isSingleSelection=false)
    • isFocused applies a highlight style (matching the hover style)
    • extraAction results in a nested main element (when element=button/a) with the extraAction element being its sibling and an additional wrapper being rendered
    • selectionMode overrides default selection semantics
    • wrapperElement correctly renders a li or div for element=button/a
    • isDisabled applies a disabled style and prevents interaction
    • textWrap (truncation and wrap) work as expected
    • hover and focus styles are correct
    • content slot props work as expected: append and prepend
    • tooltip is correctly rendered when tooltipProps is passed
    • specific passed element props apply correctly (wrapperProps, contentProps, textProps)

Checklist before marking Ready for Review

Reviewer checklist

  • Approved Impact Assessment — Acceptable to merge given the consumer impact.
  • Approved Release Readiness — Docs, Figma, and migration info are sufficient to ship.

@mgadewoll mgadewoll self-assigned this Mar 25, 2026
@mgadewoll mgadewoll added the skip-changelog Use on PRs to skip changelog requirement (Don't delete - used for automation) label Mar 25, 2026
@mgadewoll

Copy link
Copy Markdown
Contributor Author

ℹ️ Because this component is meant to be an internal only component, we're not adding a changelog for it specifically.

@mgadewoll mgadewoll changed the title [EuiListItemLayout] Add shared list item component [EuiListItemLayout] Add internal, shared list item component Mar 25, 2026
@mgadewoll
mgadewoll force-pushed the feat/548-list-item-layout branch from f4ab7f3 to 789a53a Compare March 25, 2026 13:07
@mgadewoll
mgadewoll force-pushed the feat/548-list-item-layout branch from 789a53a to 0efff42 Compare March 25, 2026 13:17
@mgadewoll
mgadewoll requested a review from ek-so March 25, 2026 13:18
@mgadewoll
mgadewoll marked this pull request as ready for review March 25, 2026 14:06
@mgadewoll
mgadewoll requested a review from a team as a code owner March 25, 2026 14:06

@ek-so ek-so left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Looking good, as discussed — left and right paddings from the text to be removed.

@mgadewoll mgadewoll mentioned this pull request Mar 27, 2026
6 of 24 tasks
@weronikaolejniczak
weronikaolejniczak self-requested a review March 31, 2026 10:02

@weronikaolejniczak weronikaolejniczak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic work, Lene! 🙌🏻 Really happy that we could create such an internal component after all, it should drive the consistency between so many list components we have. Thanks for the detailed description and QA checklist!

I have a couple of nits, one comment regarding interface and several doubts regarding behavior when going through the checklist (see below). But nothing huge... 🤞🏻

Testing notes

I usually put screenshots and details of my testing in the notes so you can see if I missed any vital area and understand better where my comments come from. But being straight from PTO and having lots on my plate, I decided to simply report what's wrong below.

I'm happy to elaborate but everything seems straightforward!

QA checklist

isSelected applies a selected style only when isSingleSelection=false

This implies when isSingleSelection=true, toggling isSelected doesn't apply selected style, right? If so, isSelected applies it no matter isSingleSelection:

Image

isSelected controls the value of aria-current when isSingleSelection (when no role is set or a non-checkable, non-selectable role is set, e.g. "presentation")

If I'm reading this correctly, aria-current shouldn't get set when toggling isSelected (and isSingleSelection=true), and the role is set to e.g. select:

Image

but it is. I'd expect aria-selected.

💭 MDN says: "If the attribute is not present, is an empty string, is present with no value, or is set to aria-current="false" it is not exposed to the user". So not setting the falsy value of aria-current is okay.

checked sets aria-checked correctly (when a checkable role is defined, e.g. "option" when isSingleSelection=false)

Role checkbox (and option as suggested) when checked is set to on/off produces aria-current="true" for both.

Image

selectionMode overrides default selection semantics

It seems like selectionMode doesn't override selection semantics... at all:

Image

I only flipped the isSelected bool to true.

Outside the checklist

isDisabled style poor affordance

It feels like there's almost no affordance to the list item actually being disabled (it's especially confusing when the list item is selected/checked). I would expect the checkbox icon bing grey instead of blue when selected, and the background as well. cc @ek-so

Image Image Image

extraAction is styled correctly.

Badge not aligned vertically

Badge seems to not be perfectly aligned vertically but it involves some sub-pixel computation so I guess it's fine. All paddings are correct.

Image Image

No description API / styles

Figma showcases a description text of lighter color, smaller font size:

Image

but there's no API for this. It seems like the consumer would have to use children and their own composition? Doesn't seem ideal for consistency.

Nested <li> elements

If you set component="li" AND add role="button" then isNonInteractiveComponent and isInteractiveComponent are both true 😅 if you add extraAction that produces nested <li> elements.

Image

@mgadewoll

mgadewoll commented Apr 1, 2026 •

Copy link
Copy Markdown
Contributor Author

@weronikaolejniczak Thanks for the very detailed review! I'm aware this PR is quite complex, your time and notes are much appreciated ❤️ I'll go over the points you flagged one by one:

1. isSelected style when isSingleSelection=true

isSelected applies a selected style only when isSingleSelection=false

This implies when isSingleSelection=true, toggling isSelected doesn't apply selected style, right? If so, isSelected >applies it no matter isSingleSelection:

It seems I messed up the instruction. isSelected only adds a visual style when isSingleSelection=true 🙈 Sorry for that.
The intention here is, that when the "checkbox" variant is rendered, the checked state itself is clear enough. But for the single selection icon variant (or no checked indicator), we'd want the additional selected style being applied.

  • showIndicator=true + isSingleSelection=true + isSelected=true -> selected style
  • showIndicator=true + isSingleSelection=false + isSelected=true -> no selected style
  • showIndicator=false + isSingleSelection=false + isSelected=true -> selected style

2. isSelected control of aria-current

isSelected controls the value of aria-current when isSingleSelection (when no role is set or a non-checkable, non-selectable role is set, e.g. "presentation")

If I'm reading this correctly, aria-current shouldn't get set when toggling isSelected (and isSingleSelection=true), and > the role is set to e.g. select:

That's an understandable thought but it's actually working correctly, afaik.
What's happening underneath is that we're checking for checkable and selectable roles, anything else gets aria-current, because:

  • aria-checked supported roles (MDN):
    • checkbox
    • menuitemcheckbox
    • menuitemradio
    • option
    • radio
    • switch
  • aria-selected supported roles (MDN):
    • gridcell
    • option
    • row
    • tab
  • aria-current supported roles (MDN):
    • Any role except for role of gridcell, option, row and tab

For "button"/"a" we're applying aria-current by default unless manually overridden.
That's currently basically just a temporary solution to support EuiSuperSelect without having to fully refactor the component. Considering we might get rid of it, we wouldn't want to increase the scope of it for this initiative.

3. checked=off results in aria-checked=true/aria-current=true

💭 MDN says: "If the attribute is not present, is an empty string, is present with no value, or is set to aria-current="false" it is not exposed to the user". So not setting the falsy value of aria-current is okay.

checked sets aria-checked correctly (when a checkable role is defined, e.g. "option" when isSingleSelection=false)

Role checkbox (and option as suggested) when checked is set to on/off produces aria-current="true" for both.

Yes, I agree that this is confusing because we don't match the native checked attribute values. Basically I kept the existing API for this from EuiSelectable (code, JSDoc). What the values mean:

  • Leave undefined to indicate not selected. Pass a string of
  • 'on' to indicate inclusion, 'off' to indicate exclusion,
  • or 'mixed' to indicate inclusion for some.
  • "on" -> included/checked
  • "off" -> excluded (anyway checked as it's selected as excluded)
  • "mixed" -> included/checked
  • undefined -> unchecked

But I think we could align the JSDoc of EuiListItemLayout with the EuiSelectable one to make that clearer.

4. selectionMode appliance

It seems like selectionMode doesn't override selection semantics... at all:

It does switch but only when allowed 😅

Screen.Recording.2026-04-01.at.09.26.01.mov

By default when no role is set, aria-current will be applied. That can't be overridden. If a checkable or selectable role is passed, selectionMode will apply.
I realize that the JSDoc is not clear enough on that.

5. isDisabled style

isDisabled style poor affordance

That's a mistake on my part. There is a proper disabled style that should be applied for any variant or state. It doesn't seem to be applied in the Playground story, but it works in the KitchenSink story.

Screenshot 2026-04-01 at 09 32 46

The issue is that I missed to pass the destructured isDisabled prop back onto the component here 🤦‍♀️

Screenshot 2026-04-01 at 09 38 43

6. Badge alignment

Badge not aligned vertically

Yeah that should be due to sub-pixels. We're relying on centering via flex here, that's the most "native" way.
There was a similar conversation on badges some time ago here (around badge text alignment) that we dropped it because we can't reliably adjust to how browsers differ in sub-pixel rendering.

7. Description API

No description API / styles

That is currently expected (Sorry for not mentioning it in the description!) We have this additional task to introduce the description API as separate step.

The reason it's separate is that adding description alone doesn't do anything. We'd actually need to update all implementations that currently use the generic slot API to then use the description API instead, which would increase the scope for updates on Kibana side.

It seems like the consumer would have to use children and their own composition?

Yes. We're keeping parity with current component usage as this update tries to keep API and usages stable (minus the few props that definitely need to be removed/adjusted). That way we keep iterations more manageable.

An example:

We add description to EuiListItemLayout. But then e.g. EuISelectableListItem needs to support that API as well. Adding another prop isn't such a big deal but to actually drive adoption we should update all usages to use description instead of passing it as part of children.

8. Nested <li> elements

If you set component="li" AND add role="button" then isNonInteractiveComponent and isInteractiveComponent are both true 😅 if you add extraAction that produces nested <li> elements.

Based on your screenshot, I think you mean wrapperComponent="li", correct?
If so, yes that results in nested <li> elements BUT it's actually not that because the inner <li> has a custom role="button", meaning it's semantically not an <li> but a <button> element 😄

@weronikaolejniczak weronikaolejniczak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, thanks for clarifying these points! I re-tested, checked recent commits and everything LGTM 🟢 This is being merged to a feature branch and things can come up later as well. Only found one more nit.

@elasticmachine

Copy link
Copy Markdown
Collaborator

💚 Build Succeeded

History

cc @mgadewoll

@elasticmachine

Copy link
Copy Markdown
Collaborator

💚 Build Succeeded

History

cc @mgadewoll

@mgadewoll
mgadewoll merged commit e5386d9 into elastic:feat/selectable-ui-enhancements Apr 1, 2026
@mgadewoll mgadewoll mentioned this pull request Apr 8, 2026
9 of 25 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog Use on PRs to skip changelog requirement (Don't delete - used for automation)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants