Skip to content

feat: support slot=label syntax on v7+ ion-select component (like ion-range)  #26838

@lincolnthree

Description

@lincolnthree

Prerequisites

Describe the Feature Request

Currently, it is not possible to provide customized labels to ion-select, rather, only the [label]="my label" attribute is supported. ion-select should be updated to support complex labels - bringing it in line with other components like ion-toggle.

Describe the Use Case

The new form syntax doesn't allow customization of ion-select labels. Making something like this impossible without using legacy <ion-label> code. We need the ability to add custom HTML / components to our labels. Plain text is not enough for our use cases:

image

Describe Preferred Solution

Pass through non-ion-select-option elements directly to the slot=label slot of ion-segment:

Use slot=label to provide custom label elements, like ion-range:

  <ion-select placeholder="Choose one">
    <div slot=label>View mode</div>
    <ion-note slot=label>Choose how decks are presented visually when viewing or editing.</ion-note>

    <ion-select-option value=foo>foo</ion-select-option>
  </ion-select>

Additionally, I'd propose that ALL input components be updated to support slot=label as appropriate. It's an extra tripping point for developers to have to remember which of these components use slot=label and which accept label elements directly as children.

Passing elements as children and having them show up in label slot without requiring the slot=label attribute might also create additional migration scenarios in the future, should components start to use the Shadow DOM, or be re-worked to use slots in the future.

If everything required slot=label today, I think it would be more consistent for developers and more future-proof across the board.

Describe Alternatives

No response

Related Code

No response

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions