toggle-group
accelya-ui-lib/toggle-groupFreeComponent
shadcn/ui publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by shadcn/ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://raw.githubusercontent.com/ramsaoji/Accelya-UI-Lib/main/public/r/styles/default/toggle-group.jsonSource
1"use client"23import * as React from "react"4import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group"5import { type VariantProps } from "class-variance-authority"67import { cn } from "@/lib/utils"8import { toggleVariants } from "@/registry/default/ui/toggle"910const ToggleGroupContext = React.createContext<11 VariantProps<typeof toggleVariants>12>({13 size: "default",14 variant: "default",15})1617const ToggleGroup = React.forwardRef<18 React.ElementRef<typeof ToggleGroupPrimitive.Root>,19 React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Root> &20 VariantProps<typeof toggleVariants>21>(({ className, variant, size, children, ...props }, ref) => (22 <ToggleGroupPrimitive.Root23 ref={ref}24 className={cn("flex items-center justify-center gap-1", className)}25 {...props}26 >27 <ToggleGroupContext.Provider value={{ variant, size }}>28 {children}29 </ToggleGroupContext.Provider>30 </ToggleGroupPrimitive.Root>31))3233ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName3435const ToggleGroupItem = React.forwardRef<36 React.ElementRef<typeof ToggleGroupPrimitive.Item>,37 React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Item> &38 VariantProps<typeof toggleVariants>39>(({ className, children, variant, size, ...props }, ref) => {40 const context = React.useContext(ToggleGroupContext)4142 return (43 <ToggleGroupPrimitive.Item44 ref={ref}45 className={cn(46 toggleVariants({47 variant: context.variant || variant,48 size: context.size || size,49 }),50 className51 )}52 {...props}53 >54 {children}55 </ToggleGroupPrimitive.Item>56 )57})5859ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName6061export { ToggleGroup, ToggleGroupItem }
What it pulls in
npm packages
Other registry items
Files it writes
More from shadcn/ui
All 357 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordionaccordion | shadcn/ui | Components | Free | 1 dep | |
| alertalert | shadcn/ui | Components | Free | no deps | |
| alert-dialogalert-dialog | shadcn/ui | Components | Free | 1 dep | |
| aspect-ratioaspect-ratio | shadcn/ui | Components | Free | 1 dep | |
| avataravatar | shadcn/ui | Components | Free | 1 dep | |
| badgebadge | shadcn/ui | Components | Free | 1 dep | |
| breadcrumbbreadcrumb | shadcn/ui | Components | Free | 1 dep | |
| buttonbutton | shadcn/ui | Components | Free | 1 dep |
