Vue NativeVue Native
Guide
Components
Composables
Navigation
  • iOS
  • Android
  • macOS
GitHub
Guide
Components
Composables
Navigation
  • iOS
  • Android
  • macOS
GitHub
  • Layout

    • VView
    • VScrollView
    • VSafeArea
    • VKeyboardAvoiding
  • Text & Input

    • VText
    • VInput
  • Interactive

    • VButton
    • VPressable
    • VSwitch
    • VSlider
    • VSegmentedControl
    • VCheckbox
    • VRadio
    • VDropdown
    • VRefreshControl
  • Media

    • VImage
    • VWebView
    • VVideo
  • Lists

    • VList
    • VFlatList
    • VSectionList
  • Feedback

    • VActivityIndicator
    • VProgressBar
    • VAlertDialog
    • VActionSheet
    • VModal
    • VErrorBoundary
  • Transition & State

    • VTransition & VTransitionGroup
    • KeepAlive
    • VSuspense
  • Navigation

    • VNavigationBar
    • VTabBar
  • System

    • VStatusBar
    • VPicker
  • macOS

    • VToolbar
    • VSplitView
    • VOutlineView

VSwitch

A boolean toggle switch. Maps to UISwitch on iOS and SwitchCompat on Android. Supports v-model for two-way binding.

Usage

<VSwitch v-model="enabled" />

Props

PropTypeDefaultDescription
modelValuebooleanfalseThe current on/off state (use with v-model)
disabledbooleanfalseDisable user interaction
onTintColorstring--Background color when the switch is on (hex string)
thumbTintColorstring--Color of the thumb circle (hex string)
styleObject--Layout styles
accessibilityLabelstring--A text label for assistive technologies
accessibilityRolestring--The accessibility role (e.g. 'switch')
accessibilityHintstring--Describes what happens when the user interacts with the element
accessibilityStateObject--Accessibility state object (e.g. { checked: true })

Events

EventPayloadDescription
@update:modelValuebooleanEmitted when toggled (used by v-model)
@changebooleanEmitted when toggled with the new value

Example

<script setup>
import { ref } from 'vue'

const notifications = ref(true)
const darkMode = ref(false)
</script>

<template>
  <VView :style="styles.container">
    <VView :style="styles.row">
      <VText :style="styles.label">Notifications</VText>
      <VSwitch v-model="notifications" onTintColor="#34C759" />
    </VView>
    <VView :style="styles.row">
      <VText :style="styles.label">Dark Mode</VText>
      <VSwitch v-model="darkMode" onTintColor="#5856D6" />
    </VView>
  </VView>
</template>

<script>
import { createStyleSheet } from '@thelacanians/vue-native-runtime'

const styles = createStyleSheet({
  container: {
    flex: 1,
    padding: 16,
  },
  row: {
    flexDirection: 'row',
    justifyContent: 'space-between',
    alignItems: 'center',
    paddingVertical: 12,
    borderBottomWidth: 1,
    borderBottomColor: '#e0e0e0',
  },
  label: {
    fontSize: 16,
  },
})
</script>
Edit this page
Last Updated: 2/28/26, 11:24 PM
Contributors: Abdul Hamid, Claude Opus 4.6
Prev
VPressable
Next
VSlider