Glass Dock
einui/glass-dockFreeComponent
A dock component with glass morphism styling and smooth animations.
Live preview
live · rendered by the registry
Rendered by einui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://ui.eindev.ir/r/glass-dock.jsonSource
1"use client"23import * as React from "react"4import { cn } from "@/lib/utils"56interface DockItem {7 id: string8 icon: React.ReactNode9 label: string10 href?: string11 onClick?: () => void12 active?: boolean13}1415type DockOrientation = "horizontal" | "vertical"1617interface GlassDockProps extends React.HTMLAttributes<HTMLDivElement> {18 items: DockItem[]19 magnification?: number20 baseSize?: number21 maxSize?: number22 orientation?: DockOrientation23 glassIntensity?: "low" | "medium" | "high"24}2526const glassConfig = {27 low: {28 bg: "bg-white/5",29 blur: "backdrop-blur-xl",30 border: "border-white/10",31 itemBg: "bg-white/5",32 itemHover: "hover:bg-white/10",33 },34 medium: {35 bg: "bg-white/10",36 blur: "backdrop-blur-2xl",37 border: "border-white/20",38 itemBg: "bg-white/10",39 itemHover: "hover:bg-white/20",40 },41 high: {42 bg: "bg-white/15",43 blur: "backdrop-blur-3xl",44 border: "border-white/30",45 itemBg: "bg-white/15",46 itemHover: "hover:bg-white/25",47 },48}4950const GlassDock = React.forwardRef<HTMLDivElement, GlassDockProps>(51 (52 {53 className,54 items,55 magnification = 1.5,56 baseSize = 48,57 maxSize = 72,58 orientation = "horizontal",59 glassIntensity = "high",60 ...props61 },62 ref,63 ) => {64 const [hoveredIndex, setHoveredIndex] = React.useState<number | null>(null)65 const [mousePos, setMousePos] = React.useState<number | null>(null)66 const dockRef = React.useRef<HTMLDivElement>(null)67 const glass = glassConfig[glassIntensity]68 const isVertical = orientation === "vertical"6970 const handleMouseMove = React.useCallback(71 (e: React.MouseEvent) => {72 if (!dockRef.current) return73 const rect = dockRef.current.getBoundingClientRect()74 setMousePos(isVertical ? e.clientY - rect.top : e.clientX - rect.left)75 },76 [isVertical],77 )7879 const handleMouseLeave = React.useCallback(() => {80 setMousePos(null)81 setHoveredIndex(null)82 }, [])8384 const getScale = React.useCallback(85 (index: number) => {86 if (mousePos === null) return 18788 const itemSize = baseSize + 1689 const itemCenter = index * itemSize + itemSize / 290 const distance = Math.abs(mousePos - itemCenter)91 const maxDistance = itemSize * 29293 if (distance > maxDistance) return 19495 const scale = 1 + (magnification - 1) * (1 - distance / maxDistance)96 return Math.min(scale, magnification)97 },98// … truncated
Files it writes
More from einui
All 44 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Base Widgetbase-widget | einui | Components | Free | 1 dep | |
| Calendar Widgetscalendar-widget | einui | Components | Free | 1 dep | |
| Clock Widgetsclock-widget | einui | Components | Free | 1 dep | |
| Glass Alert Dialogglass-alert-dialog | einui | Components | Free | 1 dep | |
| Glass Avatarglass-avatar | einui | Components | Free | 1 dep | |
| Glass Badgeglass-badge | einui | Components | Free | 1 dep | |
| Glass Breadcrumbglass-breadcrumb | einui | Components | Free | 1 dep | |
| Glass Buttonglass-button | einui | Components | Free | 2 deps |
