Skip to main content

Select

Library
UDS Base
Repository
github.com/telus/universal-design-system
Package
npmjs.com/package/@telus-uds/ds-allium
Package version
1.14.0
Loading...

Introduction

import { Select } from '@telus-uds/ds-allium'

Select is a basic form single-choice select component. You can use it in forms or individually to receive user's input.

Guidance

  • Include a placeholder to provide instructions such as "Please select..." as an unselectable option (recommended)
  • Use when options are between 7-15 (recommended)
  • For options are 6 and under, use Radio groups or ButtonGroup.
  • For options 15 and above, look for alternatives (e.g grouping into categories, or input field with auto-complete etc.)

Controlled component

If it is required that the state of the Select be controlled by the application or other external methods, value and onChange props must be passed to the Select. If the Select value should not be changed by user input, a readOnly prop must be provided.

Uncontrolled component

If it is not necessary to control the Select state, you can create one without a value prop. In this case its value can be accessed within the onChange callback. Use the initialValue prop to set the default value for an uncontrolled Select.

Getting feedback for entered values

Use the feedback prop to give the user feedback regarding their selection. You can affirm that the user's selection was correct, or highlight errors that must be corrected, using the validation prop. Keep feedback text as brief as possible, should be limited to text and links.

Loading...

Using a tooltip

When a more in-depth explanation is needed to fill out a Select properly, the tooltip prop may be used.

Grouping options

Select supports option groups. Use a Select.Group component to render an <optgroup> element with its items.

Accessibility

Select component uses label prop to set the accessibility label attribute. It also uses hint or feedback prop (depending on the validation results) to set the accessibility hint and described by (aria-describedby) attributes.

Platform considerations

The component is available on both native platforms and web.

Keep in mind though that grouping does not work on native platforms - the grouped items will be shown at the same level as the non-grouped items.

Props

NameTypeDefaultDescription
childrencomponentPropType(['Item', 'Group'])An array of items or item groups to be used as options.
inactiveboolWhether the select is disabled.
initialValuestringInitial value for the uncontrolled version.
onChangefuncCallback to be called when the value changes.
placeholderstringA placeholder to provide instructions (such as "Please select...") as an unselectable option
readOnlyboolWhether the select is read-only.
testIDstringDedicated ID for testing.
tokenscustomSystem tokens prop, see tokens for more details
valuestringCurrent value to be set as selected.
variantobjectOfSystem variant prop, see variants for more details

Tokens

In exceptional circumstances, the following tokens can be passed to this component to override its default styles. Do not do this unless absolutely necessary. Read more about overriding styles.

View Tokens
Prop NameToken PropertyToken Type
tokensbackgroundColorcolor
colorcolor
borderWidthborder
borderColorcolor
borderRadiusradius
paddingTopsize
paddingBottomsize
paddingLeftsize
paddingRightsize
heightsize
outerBackgroundColorcolor
outerBorderWidthborder
outerBorderColorcolor
fontSizefontSize
fontNamefontName
fontWeightfontWeight
iconicon
iconSizesize
iconColorcolor
validationIconicon
validationIconSizesize
validationIconColorcolor

Figma

Variants

This component does not have any stylistic variants.

Feedback