Select

Updated:

Provides single select, multiselect, and searchability with consistent visual presentation and interactions. It also supports pseudo search when a key is pressed on focus state.

Robust Content

Oftentimes, displaying more than a single line of text may become necessary to help a user make a selection. That is why, within the q2-select component, there is the ability to provide robust content for each option. This feature allows you to override the default appearance by providing custom markup to display to the user within your q2-option components.

While this may be any standard HTML you would like, we strongly suggest using the q2-item component as it is built with several design patterns in mind.

Checking Account
Savings Account
Secret Account
<q2-select label="Account" multiline-options value="2">
  <q2-option value="1">
    <q2-item>
      <div slot="header">Checking Account</div>
      <q2-detail label="Account Number" description="xxxx-2376" slot="body">
        <q2-currency amount="12953.25"></q2-currency>
      </q2-detail>
      <q2-detail label="Current Balance" slot="body">
        <q2-currency amount="12953.25"></q2-currency>
      </q2-detail>
    </q2-item>
  </q2-option>
  <q2-option value="2">
    <q2-item>
      <div slot="header">Savings Account</div>
      <q2-detail label="Account Number" description="xxxx-4595" slot="body"></q2-detail>
      <q2-detail label="Current Balance" slot="body">
        <q2-currency amount="95321.16"></q2-currency>
      </q2-detail>
    </q2-item>
  </q2-option>
  <q2-option value="3">
    <q2-item>
      <div slot="header">Secret Account</div>
      <q2-detail label="Account Number" description="xxxx-8129" slot="body"></q2-detail>
      <q2-detail label="Current Balance" slot="body">
        <q2-currency amount="8451.13"></q2-currency>
      </q2-detail>
    </q2-item>
  </q2-option>
</q2-select>

Hiding content in the selected state

Once you make a selection, the content of the selected option will be displayed in the input field. If there are elements within the robust content that you would like to hide in the selected view, you can use the hide-on-select attribute to hide them.

Customizing the height

The minimum and maximum height of the q2-select component can be modified by customizing the following CSS variables:

  • --tct-input-min-height - The minimum height of the input field. Defaults to 44px.
  • --tct-input-max-height - The maximum height of the input field. Defaults to none.

Preventing robust content in the selected state

If you do not want the robust content to be displayed in the selected state, you can use the display attribute on the q2-option component, which will tell the q2-select component that you want that text to display instead of the robust content.

Checking Account
Savings Account
Secret Account
<q2-select label="Account" multiline-options value="2">
  <q2-option value="1" display="Checking account xxxx-2376">
    <q2-item>
      <div slot="header">Checking Account</div>
      <q2-detail label="Account Number" description="xxxx-2376" slot="body">
        <q2-currency amount="12953.25"></q2-currency>
      </q2-detail>
      <q2-detail label="Current Balance" slot="body">
        <q2-currency amount="12953.25"></q2-currency>
      </q2-detail>
    </q2-item>
  </q2-option>
  <q2-option value="2" display="Savings account XXXX-4595">
    <q2-item>
      <div slot="header">Savings Account</div>
      <q2-detail label="Account Number" description="xxxx-4595" slot="body"></q2-detail>
      <q2-detail label="Current Balance" slot="body">
        <q2-currency amount="95321.16"></q2-currency>
      </q2-detail>
    </q2-item>
  </q2-option>
  <q2-option value="3" display="Secret account xxxx-8129">
    <q2-item>
      <div slot="header">Secret Account</div>
      <q2-detail label="Account Number" description="xxxx-8129" slot="body"></q2-detail>
      <q2-detail label="Current Balance" slot="body">
        <q2-currency amount="8451.13"></q2-currency>
      </q2-detail>
    </q2-item>
  </q2-option>
</q2-select>

Custom Search Functionality

By default, if a q2-select element has the searchable attribute, it will search through the provided options and display any found results. You can, however, provide a custom search function as well.

Example HTML

Option 1 Option 2 Option 3 Option 4
<q2-select label="Field label" searchable oninput="customFilterExample(event)">
  <q2-option value="1" display="Option 1">Option 1</q2-option>
  <q2-option value="2" display="Option 2">Option 2</q2-option>
  <q2-option value="3" display="Option 3" disabled>Option 3</q2-option>
  <q2-option value="4" display="Option 4">Option 4</q2-option>
</q2-select>

Example JS

function customFilterExample(event) {
  var query = event.detail.query.trim().toLowerCase();
  var optionsArr = Array.prototype.slice.call(this.querySelectorAll('q2-option'));
  optionsArr.forEach(function(option) {
    if (query === '') {
      option.style.display = '';
    } else {
      var display = option.display.toLowerCase();
      var innerText = option.innerText.toLowerCase();
      var visible = display.includes(query) || innerText.includes(query);
      option.style.display = visible ? '' : 'none';
    }
  });
}

Popover Slot Content

The popover in q2-select provides slots for custom content to be displayed persistently at the top and/or bottom of the popover menu.

Slot names:

  • "popover-top"
  • "popover-bottom"

Example HTML

Option 1 Option 2 Option 3 Option 4
Bottom Slot Content
<q2-select label="Select with Popover Slots">
  <q2-option value="1" display="Option 1">Option 1</q2-option>
  <q2-option value="2" display="Option 2">Option 2</q2-option>
  <q2-option value="3" display="Option 3">Option 3</q2-option>
  <q2-option value="4" display="Option 4">Option 4</q2-option>
  <q2-card slot='popover-top' avatar-icon="person-add" title="Add New User" description='Top Slot Content' type='clickable' is-small style='--tct-card-box-shadow: none'></q2-card>
  <div slot='popover-bottom' style='width: 100%; height: 40px;text-align: center; font-size: larger;'>Bottom Slot Content</div>
</q2-select>

The popover slots are not compatible when the hoist attribute is being used with q2-select.

Slots

The q2-select element has multiple slots that can be used to insert custom content into the component.

Learn more about slots

An optional slot to display custom content persistently at the bottom of the popover. This is not compatible with the action sheet workflow.

An optional slot to display custom content persistently at the top of the popover. This is not compatible with the action sheet workflow.

An optional slot to display custom HTML content in the display area.

Properties

The q2-select element has one or more properties that support text localization. Those properties are indicated by the localizable badge in the description.

Learn more about properties.

clearable

Renders an icon button when the field is non-empty. Pressing the button clears all input from the field.

disabled

Disables all interaction with the field and leverages the disabled visual style of q2-input.

errors

The presence of errors will mark the field as invalid, putting it into an error state.

Localizable
hideLabel
hide-label

Hide's the field's <label> element from view.

Only use when a visible label is impractical.

hoist

Instructs the component to use the action sheet workflow for displaying its options.

For more information, see Action Sheets.

If your q2-select renders inside of an iframe, and you are using multiline/robust content options, any custom CSS you apply to your options will not get passed up to the platform which displays the action sheet. For this reason, we strongly suggest using the q2-card component since its styling is managed by Tecton.

invalid

Determines whether to show an error state. Its primary use-case is for an unfilled field.

label

The text that will be used as the label for the field.

Localizable
listLabel
list-label

Determines the label that is applied to the option list for accessibility purposes.

Localizable
minRows
min-rows

The minimum number of rows the component will try to display below or above the component when opened.

multilineOptions
multiline-options

Enables text wrapping for q2-option elements. When false, the text truncates and does not wrap.

multiple

Enables multi-select functionality.

optional

Appends "(optional)" to the field label, and sets aria-required on the nested input tag to false.

placeholder

Text that appears within the field when it is blurred and empty. Placeholder text disappears when the user selects an option.

Localizable
popoverMaxHeight
popover-max-height

Force the maximum height of the popover. This value will be interpreted as pixels. If no value is passed, or the value exceeds available space, the component will auto-detect the maximum height based on available space.

popoverMode
popover-mode

Determines the display mode of the popover.

Providing a value of legacy instructs the popover to use absolute positioning instead of fixed positioning.

This is a temporary solution to work around styling issues related to using fixed positioning for the popover when nested inside of elements with transform properties. This will be removed once the popover API is available for use.

readonly

Appends "(read only)" to the field label, and field becomes unusable, but remains focusable. Takes priority over optional if both are true.

searchable

Enables search functionality.

selectedOptions
selected-options

Each item in this array should correspond to the value of a q2-option element. This property is only relevant for multiple (i.e., multi-select) implementations.

value

The current value for the select. This should correspond to the value of a nested q2-option element. This property is only relevant for single-select implementations.

Events

The q2-select element exposes events that can be used to send and receive data from the component based on user interaction.

Learn more about events.

change

Emitted when an option is selected or deselected.

When the multi-select is enabled, the value property will be undefined and the selectedOptions property will contain the selected option values.

Event Detail Type signature

{ value: string; selectedOptions: string[]; }

If an event handler is bound to the element using:

  • onchange property - The default handler will not fire, and the value must be updated in the custom handler.
  • addEventListener("change") method - The default handler will fire alongside the custom handler.

input

Emitted when the input value changes.

Requires the searchable prop to be set to true.

Event Detail Type signature

{ query: string; }

Methods

The q2-select element exposes methods that can be used to perform various actions on the component.

Learn more about methods.

closePopover

Test only

Emulates clicking the <input> to hide the popover if it is visible.

Type signature

closePopover() => Promise<void>

openPopover

Test only

Emulates clicking the <input> to display the popover if it is hidden.

Type signature

openPopover() => Promise<void>

searchOptions

Test only

Emulates focusing the <input>, entering the provided value, and emitting an input event.

Type signature

searchOptions(query: string) => Promise<void>

Only applicable when the input is searchable.

setValue

Test only

Emulates clicking the <input> to display the popover and selecting the option(s) with the specified value(s).

If the multi-select is enabled and the closePopover argument is true (default), the popover will be closed after the option(s) are selected.

Type signature

setValue(values: string | string[], options?: { closePopover?: boolean; }) => Promise<void>

Dependencies

This component uses other components in the Tecton library, including:

  • q2-popover
  • q2-option-list
  • q2-input
  • click-elsewhere

Dependents

Other components in the Tecton library use this component, including:

  • q2-pagination

Release Notes

Added support for top and bottom slots of popover

Initial Release

Overview

The Q2-select component is a dropdown selection interface that allows users to choose from a predefined list of options. It provides a space-efficient way to present multiple choices while maintaining a clean, organized interface.

When to Use Q2-Select

Primary Use Cases

Large Option Sets (5+ items) Use Q2-select when presenting 5 or more options to users. The dropdown format conserves screen real estate while providing easy access to all available choices.

Familiar Categories Ideal for commonly understood option sets such as:

  • Countries, states, or cities
  • Time zones or date ranges
  • Product categories or types
  • User roles or permissions
  • File formats or data types

When NOT to Use Q2-Select

Critical Decisions Avoid for high-stakes choices where users benefit from seeing all options simultaneously to make informed comparisons.

Frequently Changed Settings Not ideal for options that users toggle frequently, as the interaction overhead outweighs the space savings.

Complex Relationships When option dependencies or mutual exclusions are complex, more transparent selection methods may be preferable.

Q2-Select vs Q2-radio

Choose Q2-Select When:

Option Count is High

  • 5+ options that would create vertical clutter as radio buttons
  • Long lists that would require scrolling if displayed as radio buttons

Options Are Familiar

  • Users already know the available choices (e.g., selecting their home state)
  • Exploratory browsing of options is not a primary user need

Space Efficiency is Critical

  • Dense forms or compact interfaces
  • Mobile layouts where screen real estate is premium
  • Dashboard or toolbar contexts

Choose Radio Selectors When:

Option Count is Low

  • 2-4 options that can be displayed without overwhelming the interface
  • Binary or near-binary choices

Comparison is Important

  • Users need to evaluate trade-offs between options
  • Relative differences between choices are crucial to decision-making

Immediate Visibility Required

  • All options should be visible without interaction
  • No cognitive load from remembering hidden options

Content Display Decisions

Single-Line Content (Recommended Default)

Use concise, single-line labels when:

Labels Are Self-Explanatory

Options: Checking, Savings, Money Market, CD, IRA Priority: Low, Normal, High, Critical Status: Draft, Review, Approved, Published

Context Provides Clarity When the surrounding interface makes the option meaning clear without additional explanation.

Multi-Line Content (Use Selectively)

Implement robust, multi-line content when:

Options Require Explanation

`Basic Checking $9/month - Free with a Direct Deposit

Professional Checking
$29/month - Free with a Direct Deposit and a daily average balance of $5000, .05% APR

Gold Checking $99/month - Free Wires, dedicated account manager`

Differentiation is Complex When options have subtle but important differences that affect user decision-making.

Rich Context Improves Outcomes User research indicates that additional information leads to better selections and fewer errors.

User Experience

  • Default to the most commonly selected option when appropriate
  • Provide search/filter functionality for lists over 10 items
  • Consider using option groups for grouping related options with visual separators and labels

Accessibility Report

Tecton components are designed and tested to be WCAG compliant when used appropriately, and do not get released without proper validation. Developers should prefer not to set ARIA attributes when using components from the Tecton Design System.

The following CSS variables are available to override the default theme styles of the q2-selectcomponent.

Dependencies

Many Tecton components consume other components to maintain visual and functional consistency. If you are looking for a CSS variable you think should exist but are not seeing it, it may be defined in one of the dependent components below. Either way, if you think it's something we should expose more conveniently, let us know!

  • q2-input
  • There is 1 frequently asked question related to this page.