Switch is a form element that allows the user to toggle between two states. It provides a way to turn an option on or off.
The switch component comes in two sizes: small, and large. The default size is small.
The switch component allows for secondary text to be displayed. The secondary text can be placed above or below the switch, and aligned to the left or right.
The switch component comes in three statuses: checked, disabled, and invalid. The default status is unchecked.
The switch group component allows for multiple switches to be grouped together. Like any other form element, the input group can be used in a form and it has all the form element attributes.
The switch component can have background. It is useful when used on a colored background.
It can be set with type="background"
property.
The switch component can have border with border
property.
import { DapDSSwitch } from 'dap-design-system/dist/dds'
import { DapDSSwitchReact } from 'dap-design-system/dist/react'
Property | Type | Default | Description |
---|---|---|---|
border | boolean | false | This sets up border around the switch, when true. |
type | 'normal' , 'background' | 'normal' | The type of the switch |
name | string | The name of the switch. | |
value | string | The value of the switch. | |
label | string | The label of the switch. | |
description | string | The description of the switch. | |
checked | boolean | The checked state of the switch. | |
size | 'xs' , 'sm' , 'md' , 'lg' | The size of the switch. | |
disabled | boolean | The disabled state of the switch. | |
required | boolean | The required state of the switch. | |
labelPlacement | 'left' , 'right' | The placement of the label. | |
descriptionPlacement | 'top' , 'bottom' | The placement of the description. | |
subtle | boolean | The weight of the label. | |
feedback | string | The feedback of the switch. | |
feedbackType | 'negative' , 'positive' , 'warning' | The feedback type of the switch. | |
optional | boolean | The optional state of the switch. | |
optionalLabel | string | The optional label of the switch. |
No slots available.
Event Name | Description | Type |
---|---|---|
dds-change | Fired when the input value changes. | {value: string } |
dds-blur | Emitted when the input loses focus. | {void } |
dds-focus | Emitted when the input gains focus. | {void } |
dds-input | Emitted when the input receives input. | {value: string } |
Part Name | Description |
---|---|
base | The main switch container. |
baselabel | The main label container |
label | The label of the switch. |
input | The native input of the switch. |
control | The control of the switch. |
description | The description of the switch. |
No CSS custom properties available.