Toggle Group
octane/toggle-groupFreeComponent
octane publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by octane on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://raw.githubusercontent.com/octanejs/octane/main/packages/shadcn/registry/toggle-group.jsonSource
1// Base UI base toggle-group — runs on @octanejs/base-ui's ToggleGroup.2//3// THERE IS NO `Item` PART. Verified by rendering the primitive: Base UI's ToggleGroup is a single4// component whose children are ordinary `Toggle`s carrying a `value`, where radix pairs5// `ToggleGroup.Root` with `ToggleGroup.Item`. So `ToggleGroupItem` here wraps `Toggle` — the same6// primitive `toggle.tsrx` uses — and the exported names and `data-slot` values stay as shadcn7// defines them, so consumers see no difference between bases.8//9// TWO API DIFFERENCES A CONSUMER CAN OBSERVE, both inherent to the primitive:10//11// 1. `type="single" | "multiple"` is translated to Base UI's `multiple` boolean, so markup12// written against the radix base keeps working.13//14// 2. VALUES ARE ALWAYS ARRAYS. Base UI's `value` / `defaultValue` / `onValueChange` speak15// `string[]` in both modes, where radix's single mode speaks a bare `string`. That is not16// translated: faking a scalar would mean inventing conversion behavior on every change, and17// silently reshaping the argument to the consumer's handler is worse than a documented18// difference. Single mode still yields at most one entry.19//20// The pressed dialect is `data-pressed`, not radix's `data-[state=on]` — see toggle.tsrx, whose21// `toggleVariants` this file reuses, so the two bases cannot drift apart.22//23// ToggleGroup is composed with createElement: the consumer's children must sit INSIDE the context24// Provider, and opaque compiled .tsrx children can only flow through the props.children channel25// (see breadcrumb.tsrx's comment).26//27// UNVERIFIED PROVENANCE: class strings come from this package's radix base rather than28// transcribed from upstream's Base UI source.29import { createContext, createElement, useContext, type OctaneNode } from 'octane';30import { type VariantProps } from 'class-variance-authority';31import { ToggleGroup as ToggleGroupPrimitive } from '@octanejs/base-ui/toggle-group';32import { Toggle as TogglePrimitive } from '@octanejs/base-ui/toggle';3334import { cn } from '@/lib/utils';35import { toggleVariants } from '@/components/ui/toggle';3637const ToggleGroupContext = createContext<38 VariantProps<typeof toggleVariants> & {39 spacing?: number;40 orientation?: 'horizontal' | 'vertical';41 }42>({43 size: 'default',44 variant: 'default',45 spacing: 2,46 orientation: 'horizontal',47});4849export interface ToggleGroupProps extends Record<string, unknown> {50 className?: string;51// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from octane
All 44 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | octane | Components | Free | 2 deps | |
| Alertalert | octane | Components | Free | 1 dep | |
| Alert Dialogalert-dialog | octane | Components | Free | 1 dep | |
| Aspect Ratioaspect-ratio | octane | Components | Free | no deps | |
| Avataravatar | octane | Components | Free | 1 dep | |
| Badgebadge | octane | Components | Free | 1 dep | |
| Breadcrumbbreadcrumb | octane | Components | Free | 1 dep | |
| Buttonbutton | octane | Components | Free | 2 deps |
