Skip to content

Add ::part() selector support to chips in MultiSelectComboBox #4300

Closed

Description

@rolfsmeds

Describe your motivation

The vaadin-multi-select-combo-box-chip components used in vaadin-multi-select-combo-box cannot be properly styled using the ::part() selector for two reasons:

  • The chips are inside the parent element's shadow DOM, and while the chips' root elements are targetable through the chip part name, their inner parts (label, remove-button) are not.
  • The chips have their own focused state, which is only modelled as an attribute, and thus not targetable with ::part()

Describe the solution you'd like

  1. Reflect the chips' focused state as a dynamically applied part name, e.g. <vaadin-multi-select-combo-box-chip part="chip focused" ...>
  2. Expose the chips' internal parts through the parent element using exportparts, i.e. add exporparts="label:chip-label remove-button:chip-remove-button focused:chip-focused" to vaadin-multi-select-combo-box.

Describe alternatives you've considered

Alternatively, we could consider slotting the chips so that they would be in light DOM.

Additional context

We need to decide a naming scheme for sub-parts and state parts. Some options:

  • Just use a dash separator for everything: chip-remove-button, chip-focused
  • BEM style: chip__remove-button, chip--focused (__ for elements/subparts, -- for modifiers/states)

Activity

  1. jouni commented on Aug 4, 2022

    @jouni
    Member

    Would it be a feasible alternative to slot in the chips, instead of keeping them in the shadow DOM of MSCB?

  2. rolfsmeds commented on Aug 4, 2022

    @rolfsmeds
    ContributorAuthor

    Possibly – that's the plan for most (maybe all) other similar cases. Forgot to add that to the "alternatives" section, thanks.

  3. self-assigned this
    on Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions