Skip to content

Switch List

<tpg-switch-list></tpg-switch-list>

Switch Lists are the preferred way to adjust settings. They’re used to control binary options – think On/Off or True/False.

Use switches to:

  • Toggle a single item on or off
  • Immediately activate or deactivate something

The switch labels should describe what the control will do when the switch is on. Concise, positive wording is preferred, avoid negative or ambiguous toggle text like “Disable email notifications.” 

Switch Lists are always be paired with an inline label describing the option that the switch controls, as well an optional Badge to communicate its state.

Component behavior

The switch list will respond to click on the switch while not disabled or readonly, or from “Enter” and “Space” keys while having k-focus.

Examples

Switch list (Text variant)

Switch list (Badge variant)

Tables

Properties

Attribute Property Description Type Default Value
label label Label text should describe what will happen when the switch is on. string ''
read-only readOnly If true, the switch will be read-only. boolean false
disabled disabled If true, the switch will be disabled. boolean false
switch-type switchType Choose if primary text should be a regular html label or a badge. 'badge' | 'text' 'text'
secondary-label secondaryLabel Secondary text, rendered as a badge. string ''
secondary-label-uom secondaryLabelUom The UOM following the secondary text. Useless if used alone. string ''
type type The type of badge to render in terms of severity-level. If switchType is 'badge', will apply to primary Text. Otherwise applies to secondary text/badge. | 'neutral' | 'ghost' | 'not-classified' | 'classified' | 'dynamic' | 'accent' | 'ok' | 'error' | 'warning' | 'danger' 'neutral'
selected selected Sets the state of the switch, selected or not boolean false
form-associated formAssociated boolean true
name name name property for use in conjunction with html forms string

Events

Event name Reactjs attribute Description
tpg-change ontpg-change Event fired when switch state changes.

Functions

Name Description Arguments
No functions found.

Slots

Name Description
No slots found.

CSS Parts

Attribute Description
No CSS parts found.

Sandbox