Skip to content

Toggle group

Shows a group of toggle buttons.

Examples

Basic toggle group

Code

vue
<template>
  <ToggleGroup v-model="value" :items="items" type="single" />
</template>

<script setup lang="ts">
import { ToggleGroup } from '@/components/ui/toggle-group'
import { ref } from 'vue'

const value = ref(null)

const items = [
  { value: 'left', icon: 'align-left', label: 'Left' },
  { value: 'center', icon: 'align-center', label: 'Center' },
  { value: 'right', icon: 'align-right', label: 'Right' }
]
</script>

Toggle group with multiple selection

Code

vue
<template>
  <ToggleGroup v-model="value" :items="items" />
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { ToggleGroup } from '@/components/ui/toggle-group'

const value = ref([])

const items = [
  { value: 'bold', icon: 'bold', label: 'Bold' },
  { value: 'italic', icon: 'italic', label: 'Italic' },
  { value: 'underline', icon: 'underline', label: 'Underline' }
]
</script>

Toggle group with text labels

Code

vue
<template>
  <ToggleGroup v-model="value" :items="items" />
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { ToggleGroup } from '@/components/ui/toggle-group'

const value = ref([])

const items = [
  { value: 'bold', label: 'Bold' },
  { value: 'italic', label: 'Italic' },
  { value: 'underline', label: 'Underline' }
]
</script>