Skip to content

Custom states & default ARIA for slotted built-ins #10723

@LeaVerou

Description

@LeaVerou

What problem are you trying to solve?

Web components often need to slot native elements, for example:

  • A <button-group> component slotting <button> elements
  • An <x-accordion> or <sidebar-panel> component slotting <details>
  • Carousels, tab panels, etc. often need to slot existing block elements
  • A <check-list> slotting a <li> (see Allow any element to be the child of a custom element (parser weirdness permitting) #10722)
  • A <checkbox-group> slotting a <label>
  • A <x-dropdown> slotting an <option>
  • A <tab-group> or carousel component using arbitrary block elements as tab panels
  • etc

It is common to need to expose state about these slotted children to CSS (:state()), and in some cases to specify ARIA roles without spawning attributes (which is seen as an antipattern). However, given that ElementInternals is only available to custom elements, there is no states, and no way to set default ARIA, so this cannot be done.

What solutions exist today?

Components invent their own children instead of using built-ins, simply to set an ARIA attribute or to use custom states, then they have to mirror their API (and lose any heuristics about built-in elements that exist in lots of tooling or even the UA itself).

How would you solve it?

A way to attach a reduced ElementInternals to any element (just like a shadow tree can be attached to built-ins too)?

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    accessibilityAffects accessibilityaddition/proposalNew features or enhancementsneeds implementer interestMoving the issue forward requires implementers to express interesttopic: custom elementsRelates to custom elements (as defined in DOM and HTML)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions