Table
fluid-functionalism/tableFreeComponent
Animated table with proximity-based row hover highlighting and fluid border transitions. Includes TableHeader, TableBody, TableRow, TableHead, and TableCell sub-components.
Install it
npx shadcn@latest add https://fluidfunctionalism.com/r/table.jsonSource
1"use client";23import {4 useRef,5 useEffect,6 useMemo,7 createContext,8 useContext,9 forwardRef,10 type ReactNode,11 type HTMLAttributes,12 type TdHTMLAttributes,13 type ThHTMLAttributes,14} from "react";15import { motion, AnimatePresence } from "framer-motion";16import { cn } from "@/lib/utils";17import { spring } from "@/lib/springs";18import { fontWeights } from "@/lib/font-weight";19import { useProximityHover } from "@/hooks/use-proximity-hover";2021// ── Context ──────────────────────────────────────────────2223interface TableContextValue {24 registerItem: (index: number, element: HTMLElement | null) => void;25 activeIndex: number | null;26}2728const TableContext = createContext<TableContextValue | null>(null);2930// ── Table ────────────────────────────────────────────────3132interface TableProps extends HTMLAttributes<HTMLTableElement> {33 children: ReactNode;34}3536const Table = forwardRef<HTMLTableElement, TableProps>(37 ({ children, className, ...props }, ref) => {38 const containerRef = useRef<HTMLDivElement>(null);3940 const {41 activeIndex,42 itemRects,43 sessionRef,44 handlers,45 registerItem,46 measureItems,47 } = useProximityHover(containerRef);4849 useEffect(() => {50 measureItems();51 }, [measureItems, children]);5253 const activeRect = activeIndex !== null ? itemRects[activeIndex] : null;5455 const contextValue = useMemo(56 () => ({ registerItem, activeIndex }),57 [registerItem, activeIndex]58 );5960 return (61 <TableContext.Provider value={contextValue}>62 <div63 ref={containerRef}64 className="relative"65 onMouseEnter={handlers.onMouseEnter}66 onMouseMove={handlers.onMouseMove}67 onMouseLeave={handlers.onMouseLeave}68 >69 {/* Hover background */}70 <AnimatePresence>71 {activeRect && (72 <motion.div73 key={sessionRef.current}74 className="absolute bg-hover pointer-events-none"75 initial={{76 opacity: 0,77 top: activeRect.top,78 left: activeRect.left,79 width: activeRect.width,80 height: activeRect.height,81 }}82 animate={{83 opacity: 1,84// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from fluid-functionalism
All 53 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | fluid-functionalism | Components | Free | 3 deps | |
| Accordion (Base UI)accordion-base | fluid-functionalism | Components | Free | 3 deps | |
| Ask User Questionsask-user-questions | fluid-functionalism | Components | Free | 2 deps | |
| Badgebadge | fluid-functionalism | Components | Free | 1 dep | |
| Buttonbutton | fluid-functionalism | Components | Free | 4 deps | |
| Button (Base UI)button-base | fluid-functionalism | Components | Free | 4 deps | |
| Cardcard | fluid-functionalism | Components | Free | 1 dep | |
| Chat Messagechat-message | fluid-functionalism | Components | Free | 1 dep |
