πŸš€ 8.9 Released! β†’ ⚑️ New Node-API Engine Preview, πŸ“² ns widget ios, πŸ’… Tailwind v4 and more...
Read Announcement

<Switch> is a UI component that lets users toggle between two states.

xml
<Switchchecked="true" />
html
<Switchchecked="true" />
tsx
<switch
checked={switchValue}
onCheckedChange={(args) => {
setSwitchValue(args.value)
 }}
></switch>
tsx
<switch
on:checkedChange={handleChange}
checked={switchValue()}
></switch>
svelte
<switchbind:checked={switchValue}/>
vue
<Switchv-model="switchValue" />

Examples ​

Styling a Switch ​

xml
<Switchchecked="true"
color="#BFCDAC"
backgroundColor="green"
offBackgroundColor="#DC493D"
/>

Props ​

checked ​

ts
checked: boolean

Gets or sets the state switch.

Defaults to false.

offBackgroundColor ​

ts
offBackgroundColor: Color

Gets or sets the off-state background color.

See Color.

...Inherited ​

For additional inherited properties, refer to the API Reference.

Events ​

checkedChange ​

ts
on('checkedChange', (args:PropertyChangeData) => {
constswitch= args.object asSwitch
 console.log('Switch checked:', args.value)
})

See PropertyChangeData.

Native component ​

Previous
Slider

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /