NativeScript 9.1 Released → V8 14.9, Vite 8 HMR, built for rapid agentic visual iteration
Dig in

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

Examples ​

Styling a Switch ​

xml
<Switch checked="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) => {
  const switch = args.object as Switch
  console.log('Switch checked:', switch.checked)
})

See PropertyChangeData.

Native component ​

Previous
SplitView