toggle-group
ora-ui/toggle-groupFreeComponent
ora-ui publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by ora-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://ora-ui.com/r/toggle-group.jsonSource
1'use client';23import * as React from 'react';4import { Toggle as TogglePrimitive } from '@base-ui/react/toggle';5import { ToggleGroup as ToggleGroupPrimitive } from '@base-ui/react/toggle-group';6import { type VariantProps } from 'class-variance-authority';78import { cn } from '@/registry/lib/utils';9import { toggleVariants } from '@/registry/ui/toggle';1011const ToggleGroupContext = React.createContext<12 VariantProps<typeof toggleVariants> & {13 spacing?: number;14 orientation?: 'horizontal' | 'vertical';15 }16>({17 size: 'md',18 variant: 'soft',19 spacing: 0,20 orientation: 'horizontal',21});2223function ToggleGroup({24 className,25 variant,26 size,27 spacing = 0,28 orientation = 'horizontal',29 children,30 ...props31}: ToggleGroupPrimitive.Props &32 VariantProps<typeof toggleVariants> & {33 spacing?: number;34 orientation?: 'horizontal' | 'vertical';35 }) {36 return (37 <ToggleGroupPrimitive38 data-slot="toggle-group"39 data-variant={variant}40 data-size={size}41 data-spacing={spacing}42 data-orientation={orientation}43 style={{ '--gap': spacing } as React.CSSProperties}44 className={cn(45 'group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] data-[spacing=0]:data-[variant=outline]:rounded-md data-vertical:flex-col data-vertical:items-stretch',46 className47 )}48 {...props}49 >50 <ToggleGroupContext.Provider value={{ variant, size, spacing, orientation }}>51 {children}52 </ToggleGroupContext.Provider>53 </ToggleGroupPrimitive>54 );55}5657function ToggleGroupItem({58 className,59 children,60 variant = 'soft',61 size = 'md',62 ...props63}: TogglePrimitive.Props & VariantProps<typeof toggleVariants>) {64 const context = React.useContext(ToggleGroupContext);6566 return (67 <TogglePrimitive68 data-slot="toggle-group-item"69 data-variant={context.variant || variant}70 data-size={context.size || size}71 data-spacing={context.spacing}72 className={cn(73// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from ora-ui
All 31 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordionaccordion | ora-ui | Components | Free | 2 deps | |
| alert-dialogalert-dialog | ora-ui | Components | Free | 1 dep | |
| avataravatar | ora-ui | Components | Free | 1 dep | |
| avatar-groupavatar-group | ora-ui | Components | Free | no deps | |
| badgebadge | ora-ui | Components | Free | 2 deps | |
| buttonbutton | ora-ui | Components | Free | 2 deps | |
| button-groupbutton-group | ora-ui | Components | Free | 2 deps | |
| checkboxcheckbox | ora-ui | Components | Free | 3 deps |
