kliping.pro
  • Docs
  • Explore
  • Builder
  • Directory
  • Colors
  • Typeset
Saved
Docs
  • Sections13
  • Installation5
  • Dark Mode4
  • Forms3
  • Registry6
  • Utilities2
  • More10
  • Components137
  • Accordion
  • Action Bar
  • AI Chat
  • AI Thread List
  • Alert
  • Alert Dialog
  • Angle Slider
  • Animated Grid Pattern
  • Aspect Ratio
  • Attachment
  • Avatar
  • Avatar Group
  • Badge
  • Badge Overflow
  • Banner
  • Border Beam
  • Breadcrumb
  • Bubble
  • Button
  • Button Group
  • Calendar
  • Card
  • Carousel
  • Chart
  • Checkbox
  • Checkbox Group
  • Chip
  • Circular Progress
  • Client Only
  • Collapsible
  • Color Picker
  • Color Swatch
  • Combobox
  • Combobox Advanced
  • Command
  • Compare Slider
  • Composition
  • Context Menu
  • Cropper
  • Data Grid
  • Data Table
  • Data Table Advanced
  • Date Picker
  • Dialog
  • Direction Provider
  • Dot Pattern
  • Drawer
  • Dropdown Menu
  • Editable
  • Empty
  • Field
  • File Upload
  • Form
  • FPS
  • Gauge
  • Hitbox
  • Hover Card
  • Input
  • Input Group
  • Input OTP
  • Item
  • Kanban
  • Kbd
  • Kbd Advanced
  • Key Value
  • Label
  • List
  • Listbox
  • Logos
  • Map
  • Marker
  • Marquee
  • Mask Input
  • Masonry
  • Media Player
  • Mention
  • Menubar
  • Message
  • Message Scroller
  • Native Select
  • Navigation Menu
  • Number Field
  • Pagination
  • Particles
  • Pending
  • Phone Input
  • Pin Input
  • Popover
  • Portal
  • Presence
  • Progress
  • QR Code
  • Questionnaire
  • Radio Group
  • Range Calendar
  • Rating
  • Relative Time Card
  • Resizable
  • Responsive Dialog
  • Scroll Area
  • Scroll Spy
  • Scroller
  • Segmented Input
  • Select
  • Selection Toolbar
  • Separator
  • Sheet
  • Sidebar
  • Skeleton
  • Slider
  • Software Purchase Card
  • Sonner
  • Sortable
  • Speed Dial
  • Spinner
  • Stack
  • Stat
  • Status
  • Stepper
  • Stepper Advanced
  • Swap
  • Switch
  • Table
  • Tabs
  • Tags Input
  • Tags Input Advanced
  • Textarea
  • Time Picker
  • Timeline
  • Toast
  • Toggle
  • Toggle Group
  • Tooltip
  • Tour
  • Typography
  • Visually Hidden
  • Visually Hidden Input
  1. Docs
  2. Components
  3. Toggle Group

Toggle Group

PreviousNext

Sekumpulan tombol dua keadaan yang bisa dinyalakan atau dimatikan.

Docs API Reference

Installation ​

pnpm dlx kliping@latest add toggle-group

Pasang dependensi berikut:

pnpm add reka-ui

Salin dan tempel kode sumber di GitHub ke project Anda.

Sesuaikan path import dengan struktur project Anda.

Usage ​

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

<template>
  <ToggleGroup type="multiple">
    <ToggleGroupItem value="a">
      A
    </ToggleGroupItem>
    <ToggleGroupItem value="b">
      B
    </ToggleGroupItem>
    <ToggleGroupItem value="c">
      C
    </ToggleGroupItem>
  </ToggleGroup>
</template>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

Examples ​

Bawaan ​

Outline ​

Single ​

Kecil ​

Besar ​

Nonaktif ​

Requirements ​

Semua dipasang otomatis oleh kliping add; tabel ini untuk Anda yang memasang manual atau memeriksa project.

RequirementValue
ProjectVue 3.5+, Tailwind CSS v4, alias @ — disiapkan kliping init
npm packages@vueuse/core@^14.4.0, class-variance-authority@^0.7.1, reka-ui@^2.10.3
Kliping itemstoggle
Filescomponents/ui/toggle-group/toggle-group.vue
components/ui/toggle-group/toggle-group-item.vue
components/ui/toggle-group/index.ts

Anatomy ​

Susunan bagiannya seperti dipakai di contoh-contoh di atas. Impor semua bagian dari satu tempat, lalu susun begini:

vue
<ToggleGroup>
  <ToggleGroupItem />
</ToggleGroup>

API Reference ​

ToggleGroup ​

PropTypeDefaultDescription
rovingFocus?boolean—When false, navigating through the items using arrow keys will be disabled.
disabled?boolean—When true, prevents the user from interacting with the toggle group and all its items.
orientation?DataOrientation—The orientation of the component, which determines how focus moves: horizontal for left/right arrows and vertical for up/down arrows.
dir?Direction—The reading direction of the combobox when applicable.
If omitted, inherits globally from ConfigProvider or assumes LTR (left-to-right) reading mode.
loop?boolean—When loop and rovingFocus is true, keyboard navigation will loop from last item to first, and vice versa.
asChild?boolean—Change the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details.
as?AsTag | Component—The element or component this component should render as. Can be overwritten by asChild.
name?string—The name of the field. Submitted with its owning form as part of a name/value pair.
required?boolean—When true, indicates that the user must set the value before the owning form can be submitted.
type?SingleOrMultipleType—Determines whether a "single" or "multiple" items can be selected at a time. This prop will overwrite the inferred type from modelValue and defaultValue.
modelValue?AcceptableValue | AcceptableValue[]—The controlled value of the active item(s). Use this when you need to control the state of the items. Can be binded with v-model
defaultValue?AcceptableValue | AcceptableValue[]—The default active value of the item(s). Use when you do not need to control the state of the item(s).
variant?"default" | "outline"—The visual style.
size?"default" | "sm" | "lg"—The visual size.
spacing?number0Gap between items in Tailwind spacing units; 0 (default) joins the items into one bar.
EventPayloadDescription
@update:modelValue[payload: AcceptableValue | AcceptableValue[]]Emitted when the value changes.
SlotProps
#default{ modelValue: AcceptableValue | AcceptableValue[] | undefined; }
Data attributeValue
[data-slot]"toggle-group"
[data-size]"default" | "sm" | "lg"
[data-variant]"default" | "outline"
[data-spacing]number

ToggleGroupItem ​

PropTypeDefaultDescription
valueAcceptableValue—A string value for the toggle group item. All items within a toggle group should use a unique value.
disabled?boolean—When true, prevents the user from interacting with the toggle.
asChild?boolean—Change the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details.
as?AsTag | Component—The element or component this component should render as. Can be overwritten by asChild.
variant?"default" | "outline"—The visual style.
size?"default" | "sm" | "lg"—The visual size.
SlotProps
#default{ modelValue: boolean; state: DataState; pressed: boolean; disabled: boolean; }
Data attributeValue
[data-slot]"toggle-group-item"
[data-variant]"default" | "outline"
[data-size]"default" | "sm" | "lg"
[data-spacing]set at runtime

Keyboard Interactions ​

Perilaku keyboard-nya datang dari primitif Reka UI ToggleGroup yang dipakai komponen ini, mengikuti pola WAI-ARIA.

KeyDescription
TabMoves focus to either the pressed item or the first item in the group.
SpaceActivates/deactivates the item.
EnterActivates/deactivates the item.
ArrowDownMoves focus to the next item in the group.
ArrowRightMoves focus to the next item in the group.
ArrowUpMoves focus to the previous item in the group.
ArrowLeftMoves focus to the previous item in the group.
HomeMoves focus to the first item.
EndMoves focus to the last item.

CSS Variables ​

Token tema yang dibaca komponen ini — ubah nilainya di CSS global (:root dan .dark, lihat Theming) untuk mengubah tampilannya tanpa menyentuh komponennya: --radius.

Variabel khusus komponen ini — bisa ditimpa lewat style atau CSS Anda:

VariableValue
--gapdihitung saat runtime

Credits ​

Berasal dari shadcn-vue (MIT, Copyright (c) 2023 unovue). Rantai lengkapnya di Credits.

PreviousToggleNext Tooltip

On This Page

InstallationUsageExamplesBawaanOutlineSingleKecilBesarNonaktifRequirementsAnatomyAPI ReferenceToggleGroupToggleGroupItemKeyboard InteractionsCSS VariablesCredits

© 2026 Kliping. Free components are open source under the MIT License.

LicenseCreditsRoadmap