tabs
delta-components/tabsFreeComponent
delta-components publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by delta-components on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://deltacomponents.dev/r/tabs.jsonSource
1"use client"23import * as React from "react"45import { cn } from "@/lib/utils"67type TabVariant = "default" | "underline" | "ghost"8type TabSize = "sm" | "small" | "default" | "lg" | "large"910interface TabItem {11 id: string12 label: React.ReactNode13 icon?: React.ReactNode14 disabled?: boolean15}1617interface TabsContextValue {18 activeTab: string19 setActiveTab: (id: string) => void20 variant: TabVariant21 size: TabSize22 indicatorThickness?: string23 indicatorClassName?: string24 concentric?: boolean25 hoveredIndex: number | null26 setHoveredIndex: (index: number | null) => void27 activeIndex: number28 setActiveIndex: (index: number) => void29 tabRefs: React.MutableRefObject<(HTMLButtonElement | null)[]>30}3132const TabsContext = React.createContext<TabsContextValue | null>(null)3334function useTabs() {35 const context = React.useContext(TabsContext)36 if (!context) {37 throw new Error("useTabs must be used within an Tabs component")38 }39 return context40}4142interface TabsProps {43 defaultValue?: string44 value?: string45 onValueChange?: (value: string) => void46 children: React.ReactNode47 className?: string48 variant?: TabVariant49 size?: TabSize50 /** Override the underline indicator thickness (e.g. "2px", "4px") */51 indicatorThickness?: string52 /** Override the active indicator className (e.g. "bg-muted") */53 indicatorClassName?: string54 /** Use concentric border radius (outer = inner + padding) for default variant */55 concentric?: boolean56}5758function Tabs({59 defaultValue,60 value,61 onValueChange,62 children,63 className,64 variant = "default",65 size = "default",66 indicatorThickness,67 indicatorClassName,68 concentric = false,69}: TabsProps) {70 const [internalValue, setInternalValue] = React.useState(defaultValue ?? "")71 const [hoveredIndex, setHoveredIndex] = React.useState<number | null>(null)72 const [activeIndex, setActiveIndex] = React.useState<number>(0)73 const tabRefs = React.useRef<(HTMLButtonElement | null)[]>([])7475 const activeTab = value ?? internalValue76 const setActiveTab = React.useCallback(77 (id: string) => {78 if (value === undefined) {79 setInternalValue(id)80 }81 onValueChange?.(id)82 },83 [value, onValueChange]84 )8586 return (87 <TabsContext.Provider88 value={{89 activeTab,90 setActiveTab,91 variant,92 size,93 indicatorThickness,94 indicatorClassName,95 concentric,96 hoveredIndex,97 setHoveredIndex,98 activeIndex,99// … truncated
What it pulls in
npm packages
Files it writes
More from delta-components
All 93 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| admonitionadmonition | delta-components | Components | Free | 1 dep | |
| cambio-imagecambio-image | delta-components | Components | Free | 2 deps | |
| card-deckcard-deck | delta-components | Components | Free | 3 deps | |
| chatchat | delta-components | Components | Free | 3 deps | |
| code-blockcode-block | delta-components | Components | Free | 3 deps | |
| code-block-iconscode-block-icons | delta-components | Components | Free | no deps | |
| copy-buttoncopy-button | delta-components | Components | Free | 1 dep | |
| input-otpinput-otp | delta-components | Components | Free | 1 dep |
