mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 20:19:34 +01:00
74 lines
1.1 KiB
Markdown
74 lines
1.1 KiB
Markdown
---
|
|
github: true
|
|
description: Display a toggle field.
|
|
headlessui:
|
|
label: 'Switch'
|
|
to: 'https://headlessui.com/vue/switch'
|
|
---
|
|
|
|
## Usage
|
|
|
|
Use a `v-model` to make the Toggle reactive.
|
|
|
|
::component-example
|
|
#default
|
|
:toggle-example
|
|
|
|
#code
|
|
```vue
|
|
<script setup>
|
|
const selected = ref(false)
|
|
</script>
|
|
|
|
<template>
|
|
<UToggle v-model="selected" />
|
|
</template>
|
|
```
|
|
::
|
|
|
|
### Style :u-badge{label="New" class="ml-2 align-text-bottom !rounded-full"}
|
|
|
|
Use the `color` prop to change the style of the Toggle.
|
|
|
|
::component-card
|
|
---
|
|
props:
|
|
color: 'primary'
|
|
---
|
|
::
|
|
|
|
### Icon
|
|
|
|
Use any icon from [Iconify](https://icones.js.org) by setting the `on-icon` and `off-icon` props by using this pattern: `i-{collection_name}-{icon_name}` or change it globally in `ui.toggle.default.onIcon` and `ui.toggle.default.offIcon`.
|
|
|
|
::component-card
|
|
---
|
|
props:
|
|
onIcon: 'i-heroicons-check-20-solid'
|
|
offIcon: 'i-heroicons-x-mark-20-solid'
|
|
excludedProps:
|
|
- onIcon
|
|
- offIcon
|
|
---
|
|
::
|
|
|
|
### Disabled
|
|
|
|
Use the `disabled` prop to disable the Toggle.
|
|
|
|
::component-card
|
|
---
|
|
props:
|
|
disabled: true
|
|
---
|
|
::
|
|
|
|
|
|
## Props
|
|
|
|
:component-props
|
|
|
|
## Preset
|
|
|
|
:component-preset
|