Tabs
fysk/tabsFreeComponent
A set of layered sections of content—known as tab panels—that are displayed one at a time.
Install it
npx shadcn@latest add https://fysk.dev/r/tabs.jsonSource
1"use client"23import * as React from "react"4import * as TabsPrimitive from "@radix-ui/react-tabs"5import { cn } from "@/lib/utils"67// --- Types & Context ---89import { useFyskAnimation } from "@/components/hooks/useFyskAnimation"1011type TabsVariant = "default" | "glass" | "underline" | "pill"12type TabsSize = "xs" | "sm" | "md" | "lg" | "xl"1314import { useFyskConfig } from "@/components/fysk-provider"1516type TabsContextValue = {17 variant: TabsVariant18 size: TabsSize19 fullWidth?: boolean20 value?: string21 id: string22}2324const TabsContext = React.createContext<TabsContextValue>({25 variant: "default",26 size: "md",27 id: "tabs"28})2930const useTabsContext = () => React.useContext(TabsContext)3132// --- Components ---3334const Tabs = React.forwardRef<35 React.ComponentRef<typeof TabsPrimitive.Root>,36 React.ComponentPropsWithoutRef<typeof TabsPrimitive.Root> & {37 variant?: TabsVariant38 size?: TabsSize39 fullWidth?: boolean40 }41>(({ className, variant = "default", size = "md", fullWidth = false, value: propsValue, defaultValue, onValueChange, ...props }, ref) => {42 const [value, setValue] = React.useState(propsValue || defaultValue)43 const id = React.useId()4445 React.useEffect(() => {46 if (propsValue !== undefined) setValue(propsValue)47 }, [propsValue])4849 const handleValueChange = (val: string) => {50 if (propsValue === undefined) setValue(val)51 onValueChange?.(val)52 }5354 return (55 <TabsContext.Provider value={{ variant, size, fullWidth, value, id }}>56 <TabsPrimitive.Root57 ref={ref}58 value={value}59 onValueChange={handleValueChange}60 className={cn("w-full", className)}61 {...props}62 />63 </TabsContext.Provider>64 )65})66Tabs.displayName = TabsPrimitive.Root.displayName6768const TabsList = React.forwardRef<69 React.ComponentRef<typeof TabsPrimitive.List>,70 React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>71>(({ className, ...props }, ref) => {72 const { variant, size, fullWidth } = useTabsContext()7374 return (75 <TabsPrimitive.List76 ref={ref}77 className={cn(78 "inline-flex list-none items-center justify-center transition-all duration-300",79 // Height Alignment Logic80 size === "xs" && "h-8",81// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from fysk
All 18 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Avataravatar | fysk | Components | Free | 2 deps | |
| Badgebadge | fysk | Components | Free | 1 dep | |
| Buttonbutton | fysk | Components | Free | 2 deps | |
| Empty Stateempty | fysk | Components | Free | 2 deps | |
| Formform | fysk | Components | Free | 4 deps | |
| fysk-providerfysk-provider | fysk | Components | Free | 2 deps | |
| Inputinput | fysk | Components | Free | 1 dep | |
| Input OTPinput-otp | fysk | Components | Free | no deps |
