The page navigation is complete. You may now navigate the page content as you wish.
Skip to main content

Super Select

Updated in v5.0.0

An enhanced selection component that enables users to search and select items from a list of options and supports flexible custom content.

The Super Select component provides a way to select among a group of options and can be considered an enhanced version of the Select component. It supports rich content within option items, as well as custom content before and after the option items. The Super Select is built on top of ember-power-select.

Usage

When to use

  • When the list of options is large and search is required to help filter the list.
  • When complex, structured content is required to be displayed within the options.

When not to use

  • To display a list of links (or buttons) in a menu, consider the Dropdown component instead.
  • When a simple select is needed for a form, consider the Select form component.
  • As a means to filter an array of objects within a data set; e.g., when presented in a tabular format or list. Instead, consider other filtering patterns.

Components

Single

Selection is limited to a single option item.

Single selection example with list open

Multiple

Multiple options can be selected.

Multiple selection example with list open

Trigger value states

Empty

The trigger is empty by default, indicating that nothing is selected.

Showing an empty trigger, indicating to the user there is no option selected yet

Placeholder text

Placeholder text can be added to the trigger to provide the user additional context. However, this information should not be required for them to carry out a task.

Showing placeholder text inside of the trigger, still indicating no selection is made, but with some additional guidance

Filled

When one or more values are selected, the trigger is populated with the selected value(s). One or more values can be pre-selected before user interaction as needed. It is important to note that the selected values in the trigger are displayed in the order chosen by the user.

In the SuperSelect Multiple component, a count of the number of selected items displays when one or more selections have been made.

Showing preselected options in both a single and multiple variant. This helps show something has been preselected previously and the user can update their options

Before and after options

The before and after options are areas above and below the list, independent from the list of options. Predefined components (like search) or generic content can occupy these spaces.

BeforeOptions

BeforeOptions allows for either a search field or generic content to be displayed before the options list.

If enabled, search allows the user to filter results based on a query.

Search enabled before the list in both Single and Multiple components

Generic content

If enabled, generic content will occupy this space.

Generic content enabled before the list in both Single and Multiple components

Don’t

We recommend against placing heavy UI elements in custom content as it can draw attention away from the list options and will only be visible when the menu is open. Consider placing such content outside the list relative to the trigger for better visibility.

Custom content enabled before the list in both Single and Multiple components

AfterOptions

AfterOptions allows for either a standardized footer or generic content to be displayed after the options list. The footer has additional functionality in the Multiple component compared to the Single.

By default, the footer displays below the options list and contains content and/or buttons which provide additional context or functions related to the options.

Single

The footer for the Single component includes a total count, which is customizable to fit the context. However, we recommend using "{xx} total" to maintain consistency across products.

Generic content enabled before the list in both Single and Multiple components

Multiple

The footer for the Multiple component includes a total count and list modifier buttons. While the count text can be customized, we recommend using "{xx} total" to drive consistency across products.

Generic content enabled before the list in both Single and Multiple components

The “Show selected” button displays only the selected options in the list. When toggled, the text changes to “Show all.”

Flow showing the behavior of the show selected button and how it toggles the list to only display selected list items

If “Show selected” is toggled when no options have been selected, a message will appear notifying the user.

Flow showing the behavior of the show selected button when no selections have been made yet.

The “Clear selected” button clears all selections and reverts the Super Select to its default/deselected state. This button is hidden if no options are selected.

Flow showing the behavior of the clear selected button and how it reverts the Super Select's state to the default one

The footer can contain generic content instead of the default content. This is helpful in maintaining the standard appearance of the footer container while allowing for custom usage.

Showing the footer with generic content inside.

Generic content

If enabled, generic content will occupy this space.

Showing the afterOptions slot with generic content

List

Positioning

Lists can be positioned to the left or right, as well as above or below the trigger as necessary to fit within the UI. These options are only available when matchTriggerWidth is set to false. This effects the ember component only.

Showing the different list positions (left, right + top and bottom)

Width

By default, the width of the list matches the trigger width.

Showing the list's width matching the trigger's

Auto width

If the list width is set to “auto" it will match the width of the longest list item, which may result in the list being narrower or wider than the trigger width. A max-width can also be defined for the list.

Showing the list's auto width, resizing to the longest list item

ListItem Types

There are four types of ListItems, two of which are component-specific.

  • Checkmark is used in the Single component to indicate a selection has been made.
  • Checkbox is used in the Multiple component to indicate that more than one option can be selected.
  • Title is used to group ListItems together and help visually organize groups.
  • Separator is used to create a visual separation between groups.

Showing the different list types

Groups

ListItems can be grouped visually by adding a title and a separator. The last group in the list doesn’t require a separator.

Groups of list items represented in both Single and Multiple components

Required and optional

For complex forms, required fields should be indicated. This is the most explicit and transparent method to ensure users don’t have to make assumptions. Read more about best practices for marking required fields in forms.

Showing required next to the label for the Super Select

For shorter, simpler forms (e.g., login/signup and feedback requests), indicate optional fields instead.

Showing optional next to the label for the Super Select

Error validation

For error validation recommendations, refer to the Form patterns documentation.

How to use this component

Super Select is a custom select-like component aiming to overcome some limitations of the HTML <select> element.

It’s primarily a wrapper for ember-power-select and uses the 8.2.0 version with specific accessibility and styling choices that best fit our design system.

Consumer responsibility

ember-power-select 8.0, and by extension the Super Select component, requires the following line in your application.hbs. Read more about migrating from 7.0 to 8.0.

<BasicDropdownWormhole />

We provide two main components with similar APIs: Form::SuperSelect::Single and Form::SuperSelect::Multiple.

There are two ways to use each of the Super Select component types:

  1. Form::SuperSelect::Single::Base or Form::SuperSelect::Multiple::Base—the base component with just the Super Select control. In these instances, you will need to add your own label, helper text, and error messaging.
  2. Form::SuperSelect::Single::Field or Form::SuperSelect::Multiple::Field—the field parent component which includes the Super Select control, label, helper text, and error messaging (in a wrapping container).

We recommend using the Field variation as it provides built-in accessibility functionality. Use the Base variation for custom layouts or special use cases not otherwise covered.

Form::SuperSelect::Single

In cases where the Dropdown or Form Select components are not suitable, use SuperSelect::Single.

<Hds::Form::SuperSelect::Single::Field
  @onChange={{fn (mut this.SELECTED_OPTION)}}
  @selected={{this.SELECTED_OPTION}}
  @options={{this.OPTIONS}}
  @searchEnabled={{true}}
  as |F|
>
  <F.Label>This is the label</F.Label>
  <F.Options>{{F.options}}</F.Options>
</Hds::Form::SuperSelect::Single::Field>

Form::SuperSelect::Multiple

Use SuperSelect::Multiple to allow users to select multiple options.

<Hds::Form::SuperSelect::Multiple::Field
  @onChange={{fn (mut this.SELECTED_OPTIONS)}}
  @selected={{this.SELECTED_OPTIONS}}
  @options={{this.OPTIONS}}
  @searchEnabled={{true}}
  as |F|
>
  <F.Label>This is the label</F.Label>
  <F.Options>{{F.options}}</F.Options>
</Hds::Form::SuperSelect::Multiple::Field>

Pre-selected options

To pre-select an option, declare a value for the selected argument:

N. Virginia (us-east-1)
<Hds::Form::SuperSelect::Single::Field
  @onChange={{fn (mut this.PRE_SELECTED_OPTION)}}
  @selected={{this.PRE_SELECTED_OPTION}}
  @options={{this.OPTIONS}}
  @searchEnabled={{true}}
  as |F|
>
  <F.Label>Label</F.Label>
  <F.Options>{{F.options}}</F.Options>
</Hds::Form::SuperSelect::Single::Field>

Placeholder

Placeholder text can be added to provide additional context. However, this information should not be necessary for users to complete a task.

Your location
<Hds::Form::SuperSelect::Single::Field
  @onChange={{fn (mut this.PLACEHOLDER_SELECTED_OPTION)}}
  @selected={{this.PLACEHOLDER_SELECTED_OPTION}}
  @options={{this.OPTIONS}}
  @searchEnabled={{true}}
  @placeholder="Your location"
  as |F|
>
  <F.Label>Select your location of residence</F.Label>
  <F.Options>{{F.options}}</F.Options>
</Hds::Form::SuperSelect::Single::Field>

Grouped options

To group similar sets of options, pass a nested data structure specifying the groupName and associated options.

Code alert

If options are implemented as an array of strings and have the same name, they will be treated as the same, so selecting one will select others with the same name. To avoid this, implement your options using objects. (e.g. [{name: "name", label: "label"}, …])

Nested data structure example:

[
  { groupName: 'Most common', options: ['Kubernetes', 'AWS'] },
  { groupName: 'Others', options: ['CloudWise', 'SWA', 'Other'] },
]

Component invocation:

  • × Kubernetes
  • × CloudWise
<Hds::Form::SuperSelect::Multiple::Field
  @onChange={{fn (mut this.SELECTED_GROUPED_OPTIONS)}}
  @selected={{this.SELECTED_GROUPED_OPTIONS}}
  @options={{this.GROUPED_OPTIONS}}
  as |F|
>
  <F.Label>Grouped options</F.Label>
  <F.Options>{{F.options}}</F.Options>
</Hds::Form::SuperSelect::Multiple::Field>

Rich-content options

Super Select allows you to add HTML tags within options to lay out and structure content vs. Hds::FormSelect which only allows plain text strings as option content.

Rich content with default display in SuperSelect::Single

Small $0.04
2 vCPU | 2 GiB RAM
<Hds::Form::SuperSelect::Single::Field
  @onChange={{fn (mut this.SELECTED_CLUSTER_SIZE_OPTION)}}
  @selected={{this.SELECTED_CLUSTER_SIZE_OPTION}}
  @options={{this.CLUSTER_SIZE_OPTIONS}}
  as |F|
>
  <F.Label>Size</F.Label>
  <F.Options>
    {{#let F.options as |option|}}
      <Hds::Text::Body @size="200">
        <div class="doc-super-select-option-rich-header">
          <strong>{{option.size}}</strong>
          <strong>{{option.price}}</strong>
        </div>
        <div>{{option.description}}</div>
      </Hds::Text::Body>
    {{/let}}
  </F.Options>
</Hds::Form::SuperSelect::Single::Field>

Rich content with default display in SuperSelect::Multiple

By default, all content of selected options displays in the “trigger”. Visually, this looks ok in SuperSelect::Single. However, in SuperSelect::Multiple the selected items are displayed as pill-shaped “tags” so can look quite busy.

  • ×
    Small $0.04
    2 vCPU | 2 GiB RAM
  • ×
    Medium $0.08
    4 vCPU | 4 GiB RAM
<Hds::Form::SuperSelect::Multiple::Field
  @onChange={{fn (mut this.SELECTED_CLUSTER_SIZE_OPTIONS)}}
  @selected={{this.SELECTED_CLUSTER_SIZE_OPTIONS}}
  @options={{this.CLUSTER_SIZE_OPTIONS}}
  as |F|
>
  <F.Label>Size</F.Label>
  <F.Options>
    {{#let F.options as |option|}}
      <Hds::Text::Body @size="200">
        <div class="doc-super-select-option-rich-header">
          <strong>{{option.size}}</strong>
          <strong>{{option.price}}</strong>
        </div>
        <div>{{option.description}}</div>
      </Hds::Text::Body>
    {{/let}}
  </F.Options>
</Hds::Form::SuperSelect::Multiple::Field>

Selected item component

To simplify the content displayed in the selected options, use @selectedItemComponent to specify a custom component with only the content you wish to display.

An example of a custom selectedItemComponent example:

<span>
  {{@option.size}}
</span>

SuperSelect::Multiple invocation with selectedItemComponent specified:

  • × Small
  • × Medium
<Hds::Form::SuperSelect::Multiple::Field
  @onChange={{fn (mut this.SELECTED_CLUSTER_SIZE_OPTIONS)}}
  @selected={{this.SELECTED_CLUSTER_SIZE_OPTIONS}}
  @selectedItemComponent={{component "power-select/selected-option-multiple"}}
  @options={{this.CLUSTER_SIZE_OPTIONS}}
  as |F|
>
  <F.Label>Size</F.Label>
  <F.Options>
    {{#let F.options as |option|}}
      <Hds::Text::Body @size="200">
        <div class="doc-super-select-option-rich-header">
          <strong>{{option.size}}</strong>
          <strong>{{option.price}}</strong>
        </div>
        <div>{{option.description}}</div>
      </Hds::Text::Body>
    {{/let}}
  </F.Options>
</Hds::Form::SuperSelect::Multiple::Field>

SuperSelect::Single invocation with selectedItemComponent specified:

Small
<Hds::Form::SuperSelect::Single::Field
  @onChange={{fn (mut this.SELECTED_CLUSTER_SIZE_OPTION)}}
  @selected={{this.SELECTED_CLUSTER_SIZE_OPTION}}
  @selectedItemComponent={{component "power-select/selected-option-single"}}
  @options={{this.CLUSTER_SIZE_OPTIONS}}
  as |F|
>
  <F.Label>Size</F.Label>
  <F.Options>
    {{#let F.options as |option|}}
      <Hds::Text::Body @size="200">
        <div class="doc-super-select-option-rich-header">
          <strong>{{option.size}}</strong>
          <strong>{{option.price}}</strong>
        </div>
        <div>{{option.description}}</div>
      </Hds::Text::Body>
    {{/let}}
  </F.Options>
</Hds::Form::SuperSelect::Single::Field>

Limiting width

If needed, you can use dropdownMaxWidth to limit the width of the dropdown content. Setting a value for dropdownMaxWidth automatically sets matchTriggerWidth to false meaning that the width of the dropdown content will not necessarily match the list of the toggle or trigger element as it does by default.

API code
<div class="doc-super-select-constrain-width">
  <Hds::Form::SuperSelect::Single::Field
    @onChange={{fn (mut this.SELECTED_LONG_OPTION)}}
    @selected="API code"
    @options={{this.LONG_OPTIONS}}
    @dropdownMaxWidth="25em"
    as |F|
  >
    <F.Label>Choose one</F.Label>
    <F.Options>{{F.options}}</F.Options>
  </Hds::Form::SuperSelect::Single::Field>
</div>

Helper text

You can add extra information to the field using Helper Text. When helper text is added, the component automatically adds an aria-describedby attribute to the Super Select control, associating it with the automatically generated ID of the helper text element.

The target infrastructure is where you want to deploy your apps.
Kubernetes
<Hds::Form::SuperSelect::Single::Field
  @onChange={{fn (mut this.SELECTED_GROUPED_OPTION)}}
  @selected={{this.SELECTED_GROUPED_OPTION}}
  @options={{this.GROUPED_OPTIONS}}
  @ariaLabel="Label"
  as |F|
>
  <F.Label>Target infrastructure</F.Label>
  <F.HelperText>The target infrastructure is where you want to deploy your apps.</F.HelperText>
  <F.Options>{{F.options}}</F.Options>
</Hds::Form::SuperSelect::Single::Field>

Extra content in label and helper text

Accessibility consideration

If a link is used within a label, helper text, or error text, it will not be presented as a link to the user with a screen reader; only the text content is read out. As such, care should be used when considering this feature. If needing to use a link, include a screen reader-only message that informs the user that some help text includes links, and additional keyboard exploration may be required.

The Label and HelperText contextual components used in the Field component yield their content. This means you can also pass structured content.

For example:

This is an experimental feature (read more).
Kubernetes
<Hds::Form::SuperSelect::Single::Field
  @onChange={{fn (mut this.EXTRA_SELECTED_GROUPED_OPTION)}}
  @selected={{this.EXTRA_SELECTED_GROUPED_OPTION}}
  @options={{this.GROUPED_OPTIONS}}
  @ariaLabel="Label"
  as |F|
>
  <F.Label>Target infrastructure <Hds::Badge @size="small" @text="Beta" /></F.Label>
  <F.HelperText>This is an experimental feature (<Hds::Link::Inline @href="#">read more</Hds::Link::Inline>).</F.HelperText>
  <F.Options>{{F.options}}</F.Options>
</Hds::Form::SuperSelect::Single::Field>

Required vs. optional

Use the @isRequired and @isOptional arguments to add a visual indication that the field is "required" or "optional".

The page navigation is complete. You may now navigate the page content as you wish.
Skip to main content

Super Select

Updated in v5.0.0

An enhanced selection component that enables users to search and select items from a list of options and supports flexible custom content.

The Super Select component provides a way to select among a group of options and can be considered an enhanced version of the Select component. It supports rich content within option items, as well as custom content before and after the option items. The Super Select is built on top of ember-power-select.

Usage

When to use

  • When the list of options is large and search is required to help filter the list.
  • When complex, structured content is required to be displayed within the options.

When not to use

  • To display a list of links (or buttons) in a menu, consider the Dropdown component instead.
  • When a simple select is needed for a form, consider the Select form component.
  • As a means to filter an array of objects within a data set; e.g., when presented in a tabular format or list. Instead, consider other filtering patterns.

Components

Single

Selection is limited to a single option item.

Single selection example with list open

Multiple

Multiple options can be selected.

Multiple selection example with list open

Trigger value states

Empty

The trigger is empty by default, indicating that nothing is selected.

Showing an empty trigger, indicating to the user there is no option selected yet

Placeholder text

Placeholder text can be added to the trigger to provide the user additional context. However, this information should not be required for them to carry out a task.

Showing placeholder text inside of the trigger, still indicating no selection is made, but with some additional guidance

Filled

When one or more values are selected, the trigger is populated with the selected value(s). One or more values can be pre-selected before user interaction as needed. It is important to note that the selected values in the trigger are displayed in the order chosen by the user.

In the SuperSelect Multiple component, a count of the number of selected items displays when one or more selections have been made.

Showing preselected options in both a single and multiple variant. This helps show something has been preselected previously and the user can update their options

Before and after options

The before and after options are areas above and below the list, independent from the list of options. Predefined components (like search) or generic content can occupy these spaces.

BeforeOptions

BeforeOptions allows for either a search field or generic content to be displayed before the options list.

If enabled, search allows the user to filter results based on a query.

Search enabled before the list in both Single and Multiple components

Generic content

If enabled, generic content will occupy this space.

Generic content enabled before the list in both Single and Multiple components

Don’t

We recommend against placing heavy UI elements in custom content as it can draw attention away from the list options and will only be visible when the menu is open. Consider placing such content outside the list relative to the trigger for better visibility.

Custom content enabled before the list in both Single and Multiple components

AfterOptions

AfterOptions allows for either a standardized footer or generic content to be displayed after the options list. The footer has additional functionality in the Multiple component compared to the Single.

By default, the footer displays below the options list and contains content and/or buttons which provide additional context or functions related to the options.

Single

The footer for the Single component includes a total count, which is customizable to fit the context. However, we recommend using "{xx} total" to maintain consistency across products.

Generic content enabled before the list in both Single and Multiple components

Multiple

The footer for the Multiple component includes a total count and list modifier buttons. While the count text can be customized, we recommend using "{xx} total" to drive consistency across products.

Generic content enabled before the list in both Single and Multiple components

The “Show selected” button displays only the selected options in the list. When toggled, the text changes to “Show all.”

Flow showing the behavior of the show selected button and how it toggles the list to only display selected list items

If “Show selected” is toggled when no options have been selected, a message will appear notifying the user.

Flow showing the behavior of the show selected button when no selections have been made yet.

The “Clear selected” button clears all selections and reverts the Super Select to its default/deselected state. This button is hidden if no options are selected.

Flow showing the behavior of the clear selected button and how it reverts the Super Select's state to the default one

The footer can contain generic content instead of the default content. This is helpful in maintaining the standard appearance of the footer container while allowing for custom usage.

Showing the footer with generic content inside.

Generic content

If enabled, generic content will occupy this space.

Showing the afterOptions slot with generic content

List

Positioning

Lists can be positioned to the left or right, as well as above or below the trigger as necessary to fit within the UI. These options are only available when matchTriggerWidth is set to false. This effects the ember component only.

Showing the different list positions (left, right + top and bottom)

Width

By default, the width of the list matches the trigger width.

Showing the list's width matching the trigger's

Auto width

If the list width is set to “auto" it will match the width of the longest list item, which may result in the list being narrower or wider than the trigger width. A max-width can also be defined for the list.

Showing the list's auto width, resizing to the longest list item

ListItem Types

There are four types of ListItems, two of which are component-specific.

  • Checkmark is used in the Single component to indicate a selection has been made.
  • Checkbox is used in the Multiple component to indicate that more than one option can be selected.
  • Title is used to group ListItems together and help visually organize groups.
  • Separator is used to create a visual separation between groups.

Showing the different list types

Groups

ListItems can be grouped visually by adding a title and a separator. The last group in the list doesn’t require a separator.

Groups of list items represented in both Single and Multiple components

Required and optional

For complex forms, required fields should be indicated. This is the most explicit and transparent method to ensure users don’t have to make assumptions. Read more about best practices for marking required fields in forms.

Showing required next to the label for the Super Select

For shorter, simpler forms (e.g., login/signup and feedback requests), indicate optional fields instead.

Showing optional next to the label for the Super Select

Error validation

For error validation recommendations, refer to the Form patterns documentation.

How to use this component

Super Select is a custom select-like component aiming to overcome some limitations of the HTML <select> element.

It’s primarily a wrapper for ember-power-select and uses the 8.2.0 version with specific accessibility and styling choices that best fit our design system.

Consumer responsibility

ember-power-select 8.0, and by extension the Super Select component, requires the following line in your application.hbs. Read more about migrating from 7.0 to 8.0.

<BasicDropdownWormhole />

We provide two main components with similar APIs: Form::SuperSelect::Single and Form::SuperSelect::Multiple.

There are two ways to use each of the Super Select component types:

  1. Form::SuperSelect::Single::Base or Form::SuperSelect::Multiple::Base—the base component with just the Super Select control. In these instances, you will need to add your own label, helper text, and error messaging.
  2. Form::SuperSelect::Single::Field or Form::SuperSelect::Multiple::Field—the field parent component which includes the Super Select control, label, helper text, and error messaging (in a wrapping container).

We recommend using the Field variation as it provides built-in accessibility functionality. Use the Base variation for custom layouts or special use cases not otherwise covered.

Form::SuperSelect::Single

In cases where the Dropdown or Form Select components are not suitable, use SuperSelect::Single.

<Hds::Form::SuperSelect::Single::Field
  @onChange={{fn (mut this.SELECTED_OPTION)}}
  @selected={{this.SELECTED_OPTION}}
  @options={{this.OPTIONS}}
  @searchEnabled={{true}}
  as |F|
>
  <F.Label>This is the label</F.Label>
  <F.Options>{{F.options}}</F.Options>
</Hds::Form::SuperSelect::Single::Field>

Form::SuperSelect::Multiple

Use SuperSelect::Multiple to allow users to select multiple options.

<Hds::Form::SuperSelect::Multiple::Field
  @onChange={{fn (mut this.SELECTED_OPTIONS)}}
  @selected={{this.SELECTED_OPTIONS}}
  @options={{this.OPTIONS}}
  @searchEnabled={{true}}
  as |F|
>
  <F.Label>This is the label</F.Label>
  <F.Options>{{F.options}}</F.Options>
</Hds::Form::SuperSelect::Multiple::Field>

Pre-selected options

To pre-select an option, declare a value for the selected argument:

N. Virginia (us-east-1)
<Hds::Form::SuperSelect::Single::Field
  @onChange={{fn (mut this.PRE_SELECTED_OPTION)}}
  @selected={{this.PRE_SELECTED_OPTION}}
  @options={{this.OPTIONS}}
  @searchEnabled={{true}}
  as |F|
>
  <F.Label>Label</F.Label>
  <F.Options>{{F.options}}</F.Options>
</Hds::Form::SuperSelect::Single::Field>

Placeholder

Placeholder text can be added to provide additional context. However, this information should not be necessary for users to complete a task.

Your location
<Hds::Form::SuperSelect::Single::Field
  @onChange={{fn (mut this.PLACEHOLDER_SELECTED_OPTION)}}
  @selected={{this.PLACEHOLDER_SELECTED_OPTION}}
  @options={{this.OPTIONS}}
  @searchEnabled={{true}}
  @placeholder="Your location"
  as |F|
>
  <F.Label>Select your location of residence</F.Label>
  <F.Options>{{F.options}}</F.Options>
</Hds::Form::SuperSelect::Single::Field>

Grouped options

To group similar sets of options, pass a nested data structure specifying the groupName and associated options.

Code alert

If options are implemented as an array of strings and have the same name, they will be treated as the same, so selecting one will select others with the same name. To avoid this, implement your options using objects. (e.g. [{name: "name", label: "label"}, …])

Nested data structure example:

[
  { groupName: 'Most common', options: ['Kubernetes', 'AWS'] },
  { groupName: 'Others', options: ['CloudWise', 'SWA', 'Other'] },
]

Component invocation:

  • × Kubernetes
  • × CloudWise
<Hds::Form::SuperSelect::Multiple::Field
  @onChange={{fn (mut this.SELECTED_GROUPED_OPTIONS)}}
  @selected={{this.SELECTED_GROUPED_OPTIONS}}
  @options={{this.GROUPED_OPTIONS}}
  as |F|
>
  <F.Label>Grouped options</F.Label>
  <F.Options>{{F.options}}</F.Options>
</Hds::Form::SuperSelect::Multiple::Field>

Rich-content options

Super Select allows you to add HTML tags within options to lay out and structure content vs. Hds::FormSelect which only allows plain text strings as option content.

Rich content with default display in SuperSelect::Single

Small $0.04
2 vCPU | 2 GiB RAM
<Hds::Form::SuperSelect::Single::Field
  @onChange={{fn (mut this.SELECTED_CLUSTER_SIZE_OPTION)}}
  @selected={{this.SELECTED_CLUSTER_SIZE_OPTION}}
  @options={{this.CLUSTER_SIZE_OPTIONS}}
  as |F|
>
  <F.Label>Size</F.Label>
  <F.Options>
    {{#let F.options as |option|}}
      <Hds::Text::Body @size="200">
        <div class="doc-super-select-option-rich-header">
          <strong>{{option.size}}</strong>
          <strong>{{option.price}}</strong>
        </div>
        <div>{{option.description}}</div>
      </Hds::Text::Body>
    {{/let}}
  </F.Options>
</Hds::Form::SuperSelect::Single::Field>

Rich content with default display in SuperSelect::Multiple

By default, all content of selected options displays in the “trigger”. Visually, this looks ok in SuperSelect::Single. However, in SuperSelect::Multiple the selected items are displayed as pill-shaped “tags” so can look quite busy.

  • ×
    Small $0.04
    2 vCPU | 2 GiB RAM
  • ×
    Medium $0.08
    4 vCPU | 4 GiB RAM
<Hds::Form::SuperSelect::Multiple::Field
  @onChange={{fn (mut this.SELECTED_CLUSTER_SIZE_OPTIONS)}}
  @selected={{this.SELECTED_CLUSTER_SIZE_OPTIONS}}
  @options={{this.CLUSTER_SIZE_OPTIONS}}
  as |F|
>
  <F.Label>Size</F.Label>
  <F.Options>
    {{#let F.options as |option|}}
      <Hds::Text::Body @size="200">
        <div class="doc-super-select-option-rich-header">
          <strong>{{option.size}}</strong>
          <strong>{{option.price}}</strong>
        </div>
        <div>{{option.description}}</div>
      </Hds::Text::Body>
    {{/let}}
  </F.Options>
</Hds::Form::SuperSelect::Multiple::Field>

Selected item component

To simplify the content displayed in the selected options, use @selectedItemComponent to specify a custom component with only the content you wish to display.

An example of a custom selectedItemComponent example:

<span>
  {{@option.size}}
</span>

SuperSelect::Multiple invocation with selectedItemComponent specified:

  • × Small
  • × Medium
<Hds::Form::SuperSelect::Multiple::Field
  @onChange={{fn (mut this.SELECTED_CLUSTER_SIZE_OPTIONS)}}
  @selected={{this.SELECTED_CLUSTER_SIZE_OPTIONS}}
  @selectedItemComponent={{component "power-select/selected-option-multiple"}}
  @options={{this.CLUSTER_SIZE_OPTIONS}}
  as |F|
>
  <F.Label>Size</F.Label>
  <F.Options>
    {{#let F.options as |option|}}
      <Hds::Text::Body @size="200">
        <div class="doc-super-select-option-rich-header">
          <strong>{{option.size}}</strong>
          <strong>{{option.price}}</strong>
        </div>
        <div>{{option.description}}</div>
      </Hds::Text::Body>
    {{/let}}
  </F.Options>
</Hds::Form::SuperSelect::Multiple::Field>

SuperSelect::Single invocation with selectedItemComponent specified:

Small
<Hds::Form::SuperSelect::Single::Field
  @onChange={{fn (mut this.SELECTED_CLUSTER_SIZE_OPTION)}}
  @selected={{this.SELECTED_CLUSTER_SIZE_OPTION}}
  @selectedItemComponent={{component "power-select/selected-option-single"}}
  @options={{this.CLUSTER_SIZE_OPTIONS}}
  as |F|
>
  <F.Label>Size</F.Label>
  <F.Options>
    {{#let F.options as |option|}}
      <Hds::Text::Body @size="200">
        <div class="doc-super-select-option-rich-header">
          <strong>{{option.size}}</strong>
          <strong>{{option.price}}</strong>
        </div>
        <div>{{option.description}}</div>
      </Hds::Text::Body>
    {{/let}}
  </F.Options>
</Hds::Form::SuperSelect::Single::Field>

Limiting width

If needed, you can use dropdownMaxWidth to limit the width of the dropdown content. Setting a value for dropdownMaxWidth automatically sets matchTriggerWidth to false meaning that the width of the dropdown content will not necessarily match the list of the toggle or trigger element as it does by default.

API code
<div class="doc-super-select-constrain-width">
  <Hds::Form::SuperSelect::Single::Field
    @onChange={{fn (mut this.SELECTED_LONG_OPTION)}}
    @selected="API code"
    @options={{this.LONG_OPTIONS}}
    @dropdownMaxWidth="25em"
    as |F|
  >
    <F.Label>Choose one</F.Label>
    <F.Options>{{F.options}}</F.Options>
  </Hds::Form::SuperSelect::Single::Field>
</div>

Helper text

You can add extra information to the field using Helper Text. When helper text is added, the component automatically adds an aria-describedby attribute to the Super Select control, associating it with the automatically generated ID of the helper text element.

The target infrastructure is where you want to deploy your apps.
Kubernetes
<Hds::Form::SuperSelect::Single::Field
  @onChange={{fn (mut this.SELECTED_GROUPED_OPTION)}}
  @selected={{this.SELECTED_GROUPED_OPTION}}
  @options={{this.GROUPED_OPTIONS}}
  @ariaLabel="Label"
  as |F|
>
  <F.Label>Target infrastructure</F.Label>
  <F.HelperText>The target infrastructure is where you want to deploy your apps.</F.HelperText>
  <F.Options>{{F.options}}</F.Options>
</Hds::Form::SuperSelect::Single::Field>

Extra content in label and helper text

Accessibility consideration

If a link is used within a label, helper text, or error text, it will not be presented as a link to the user with a screen reader; only the text content is read out. As such, care should be used when considering this feature. If needing to use a link, include a screen reader-only message that informs the user that some help text includes links, and additional keyboard exploration may be required.

The Label and HelperText contextual components used in the Field component yield their content. This means you can also pass structured content.

For example:

This is an experimental feature (read more).
Kubernetes
<Hds::Form::SuperSelect::Single::Field
  @onChange={{fn (mut this.EXTRA_SELECTED_GROUPED_OPTION)}}
  @selected={{this.EXTRA_SELECTED_GROUPED_OPTION}}
  @options={{this.GROUPED_OPTIONS}}
  @ariaLabel="Label"
  as |F|
>
  <F.Label>Target infrastructure <Hds::Badge @size="small" @text="Beta" /></F.Label>
  <F.HelperText>This is an experimental feature (<Hds::Link::Inline @href="#">read more</Hds::Link::Inline>).</F.HelperText>
  <F.Options>{{F.options}}</F.Options>
</Hds::Form::SuperSelect::Single::Field>

Required vs. optional

Use the @isRequired and @isOptional arguments to add a visual indication that the field is "required" or "optional".