tabs
pane/tabsFreeComponent
pane publishes no description for this item.
Install it
npx shadcn@latest add https://pane.theui.company/r/tabs.jsonSource
1"use client";23import { motion } from "motion/react";4import { Tabs as TabsPrimitive } from "radix-ui";5import * as React from "react";6import { Pane } from "@/components/ui/pane";7import { GLASS_SPRING } from "@/lib/glass/config";8import { cn } from "@/lib/utils";910interface TabsContextValue {11 value?: string;12 indicatorId: string;13}1415const TabsContext = React.createContext<TabsContextValue | null>(null);1617function Tabs({18 value,19 defaultValue,20 onValueChange,21 className,22 ...props23}: React.ComponentProps<typeof TabsPrimitive.Root>) {24 const indicatorId = React.useId();25 const [internalValue, setInternalValue] = React.useState(defaultValue);26 const activeValue = value ?? internalValue;2728 return (29 <TabsContext.Provider value={{ value: activeValue, indicatorId }}>30 <TabsPrimitive.Root31 value={value}32 defaultValue={defaultValue}33 onValueChange={(next) => {34 setInternalValue(next);35 onValueChange?.(next);36 }}37 data-slot="tabs"38 className={cn("flex flex-col gap-2", className)}39 {...props}40 />41 </TabsContext.Provider>42 );43}4445function TabsList({46 className,47 ...props48}: React.ComponentProps<typeof TabsPrimitive.List>) {49 return (50 <Pane variant="clear" radius={16} className="inline-flex w-fit">51 <TabsPrimitive.List52 data-slot="tabs-list"53 className={cn(54 "relative inline-flex h-10 items-center gap-1 p-1",55 className,56 )}57 {...props}58 />59 </Pane>60 );61}6263function TabsTrigger({64 className,65 value,66 children,67 ...props68}: React.ComponentProps<typeof TabsPrimitive.Trigger>) {69 const ctx = React.useContext(TabsContext);70 const isActive = ctx?.value === value;7172 return (73 <TabsPrimitive.Trigger74 value={value}75 data-slot="tabs-trigger"76 className={cn(77 "relative inline-flex h-8 flex-1 items-center justify-center gap-1.5 whitespace-nowrap rounded-xl px-3 text-sm font-medium text-muted-foreground outline-none transition-colors focus-visible:ring-2 focus-visible:ring-[var(--pane-highlight)] disabled:pointer-events-none disabled:opacity-50 data-[state=active]:text-foreground [&_svg]:size-4 [&_svg]:shrink-0",78 className,79 )}80 {...props}81 >82 {isActive ? (83 <motion.div84 layoutId={`${ctx?.indicatorId}-indicator`}85 transition={GLASS_SPRING.hover}86 className="absolute inset-0"87 >88// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from pane
All 25 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| badgebadge | pane | Components | Free | 2 deps | |
| buttonbutton | pane | Components | Free | 2 deps | |
| cardcard | pane | Components | Free | no deps | |
| dialogdialog | pane | Components | Free | 2 deps | |
| inputinput | pane | Components | Free | no deps | |
| panepane | pane | Components | Free | 1 dep | |
| sheetsheet | pane | Components | Free | 3 deps | |
| switchswitch | pane | Components | Free | 2 deps |
