Filter Grid
NewInstallation
npx shadcn@latest add https://uibrik.com/r/filter-grid.jsonInstall the packages
npm install @tabler/icons-react motion react-use-measureAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/filter-grid/filter-grid.tsx"use client"; import { useId, useMemo, useRef, useState, type KeyboardEvent, type ReactNode } from "react"; import { AnimatePresence, LayoutGroup, MotionConfig, motion } from "motion/react"; import useMeasure from "react-use-measure"; import { IconBug, IconCalendarEvent, IconChartPie, IconFileInvoice, IconGitPullRequest, IconLayoutBoard, IconListCheck, IconMail, IconPalette, IconReceipt, IconRocket, IconTypography, } from "@tabler/icons-react"; import { cn } from "@/lib/utils"; // Filter grid. Tabs over a grid of tiles, where a tile can belong to several // tabs. Switching tabs slides the highlight across; tiles in both tabs glide // to their new places, tiles that leave blur and shrink away, and tiles that
Adds the files to
components/uibrik/filter-grid and installs @tabler/icons-react, motion and react-use-measure. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/filter-grid.Props
FilterGrid- counts
- Type boolean
- true
- Show how many tiles each tab holds.
- duration
- Type number
- 0.55
- How long a move takes.
- bounce
- Type number
- 0.12
- Springiness of a move. 0 settles without overshoot.
- stagger
- Type number
- 35
- Delay between tiles growing in.
- minColumnWidth
- Type number
- 200
- Narrowest a column gets before the grid drops one.
- gap
- Type number
- 10
- Space between tiles.
- radius
- Type number
- 16
- Corner radius of a tile.
- tabs
- Type { id: string; label: string }[]
- SAMPLE_TABS
- Tabs in order.
- items
- Type { id: string; title: string; description?: string; tags: string[]; icon?: ReactNode }[]
- SAMPLE_ITEMS
- Tiles in order. tags are the ids of the tabs a tile shows under; tiles in several tabs glide between them.
- value / onChange
- Type string / (tab) => void
- –
- Controlled tab id.
- defaultValue
- Type string
- –
- Tab selected to begin with. Defaults to the first.
- onSelect
- Type (item) => void
- –
- Makes tiles buttons and is called with the one pressed.
- label
- Type string
- "Filter"
- Names the tabs for screen readers.
- className
- Type string
- –
- Classes for the wrapper.