Dynamic Toolbar
uselayouts/dynamic-toolbarFreeComponent
A toolbar that adapts its size and layout based on content.
Live preview
live · rendered by the registry
Rendered by uselayouts on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://uselayouts.com/r/dynamic-toolbar.jsonSource
1"use client";2import { delay, motion } from "motion/react";3import React, { useEffect, useRef, useState } from "react";4import {5 InboxIcon,6 Message01Icon,7 PaintBoardIcon,8 Tag01Icon,9 Image01Icon,10 Archive02Icon,11 ArrowReloadHorizontalIcon,12 Delete02Icon,13 ArrowRight01Icon,14 ArrowLeft01Icon,15} from "@hugeicons/core-free-icons";16import { HugeiconsIcon } from "@hugeicons/react";17import useMeasure from "@/hooks/use-measure";1819const ICON_SIZE = 24;2021// Change Here22const primaryTools = [23 { icon: InboxIcon, label: "Inbox" },24 { icon: Message01Icon, label: "Messages" },25 { icon: PaintBoardIcon, label: "Paint" },26 { icon: Tag01Icon, label: "Tags", blur: true },27];2829const secondaryTools = [30 { icon: Image01Icon, label: "Image", blur: true },31 { icon: Archive02Icon, label: "Archive" },32 {33 icon: ArrowReloadHorizontalIcon,34 label: "Reload",35 className: "-scale-x-100",36 },37 {38 icon: ArrowReloadHorizontalIcon,39 label: "Reload",40 className: "-scale-x-100",41 },42 { icon: Delete02Icon, label: "Delete", className: "text-red-500" },43];4445function ToolbarButton({46 icon,47 size = ICON_SIZE,48 blur = false,49 isBlurred = false,50 className = "",51}: {52 icon: any;53 size?: number;54 blur?: boolean;55 isBlurred?: boolean;56 className?: string;57}) {58 const iconElement = (59 <HugeiconsIcon60 icon={icon}61 className={`text-foreground ${className}`}62 width={size}63 height={size}64 />65 );6667 if (blur) {68 return (69 <button className="p-1 rounded-md hover:bg-accent/50 transition-colors hover:cursor-pointer">70 <motion.div71 initial={{ filter: "blur(0px)" }}72 animate={{ filter: isBlurred ? "blur(1px)" : "blur(0px)" }}73 >74 {iconElement}75 </motion.div>76 </button>77 );78 }7980 return (81 <button className="p-1 rounded-md hover:bg-accent/50 transition-colors hover:cursor-pointer ">82 {iconElement}83 </button>84 );85}8687function ExtendedToolbar() {88 const [isExpanded, setIsExpanded] = useState(false);89 const [isMounted, setIsMounted] = useState(false);90 const [primaryRef, primaryBounds] = useMeasure();91 const [secondaryRef, secondaryBounds] = useMeasure();9293 useEffect(() => {94 setIsMounted(true);95 }, []);9697 const currentWidth = isExpanded ? secondaryBounds.width : primaryBounds.width;98 const hasMeasurements = primaryBounds.width > 0;99100 const initialWidth = hasMeasurements ? primaryBounds.width : "auto";101102 const springTransition = {103// … truncated
What it pulls in
npm packages
Files it writes
More from uselayouts
All 26 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| 3D Book3d-book | uselayouts | Components | Free | 3 deps | |
| Animated Collectionanimated-collection | uselayouts | Components | Free | 5 deps | |
| Bento Cardbento-card | uselayouts | Components | Free | 5 deps | |
| Bottom Menubottom-menu | uselayouts | Components | Free | 6 deps | |
| Bucketbucket | uselayouts | Components | Free | 5 deps · 2 files | |
| Day Pickerday-picker | uselayouts | Components | Free | 5 deps | |
| Delete Buttondelete-button | uselayouts | Components | Free | 5 deps | |
| Discover Buttondiscover-button | uselayouts | Components | Free | 5 deps |
