- Label
- Icon label
- Field
- Form
- Frontmatter form
- Questionnaire
- Input
- Input group
- Input OTP
- Password input
- Password strength
- Code input
- Number field
- Tag input
- Textarea
- Checkbox
- Radio group
- Language toggle group
- Emoji appearance toggle group
- Emoji picker
- Avatar picker
- AI provider picker
- Select
- Native select
- Combobox
- Language combobox
- Slider
- Calendar
- Switch
- Alert
- Avatar
- Badge
- Card
- AI provider card
- Model info card
- Model list
- Empty
- Item
- Tree item
- File tree
- Icon media
- File type icon
- Font preview
- Image preview
- Kbd
- Table
- Data table
- Data table column header
- Chart
- Code Block
- Code card
- Markdown view
- Attachment
- Bubble
- Marker
- Message
- Chat message
- Chat suggestion item
- Message scroller
- Trace
- Progress
- Spinner
- Sonner
- Toast
- Unsaved changes toolbar
- Unsaved indicator
- Status indicator
- Permission card
- Separator
- Skeleton
- Animated grid pattern
- Meteors
Every language shown inline as a single-choice toggle group, which never deselects so a language is always chosen.
Installation#
pnpm dlx shadcn@latest add @zui/language-toggle-groupThe CLI writes components/data-entry/language-toggle-group.tsx and installs
Toggle group with the items it needs.
Usage#
import { LanguageToggleGroup } from '@/components/data-entry/language-toggle-group';
import { Text } from '@/components/ui/text';
import { ToggleGroupItem } from '@/components/ui/toggle-group';<LanguageToggleGroup value={language} onValueChange={setLanguage} aria-label="Language">
<ToggleGroupItem value="en">
<Text>English</Text>
</ToggleGroupItem>
<ToggleGroupItem value="es">
<Text>Spanish</Text>
</ToggleGroupItem>
</LanguageToggleGroup>Compose one ToggleGroupItem per option, as the group's direct children. Use it for a small, fixed set of two to
four languages; for a longer or searchable list, use a Combobox instead.
API reference#
LanguageToggleGroup#
Takes every prop of ToggleGroup except type, which it fixes to
single, and value and onValueChange, which are redefined:
| Prop | Type | Default |
|---|---|---|
value | string | required |
onValueChange | (value: string) => void | required |
It is announced as a radio group, named by its aria-label, and each item as a radio, checked while its value
equals the group's. Pressing the checked item reports nothing, so a language is always chosen. It defaults
variant to outline and keeps the toggle group's default spacing.
Differences from the web#
- Its label goes in each item as a Text child, where the web's item takes the string itself.
- The web's
data-slotattribute is not set; a View takes no data attributes.