Forms & inputs / Dropdown lists & combo boxes
Pill Select Filter
Small white pill dropdown labelled 'All industries' with chevron and hairline ring, aligned right of a large section heading.
Rebuilt from vercel.com/customers in the Monochrome Precision style.
npx shadcn@latest add https://yoink-app.fly.dev/r/monochrome-precision/blocks/industry-filter-select.json
Looks exactly like vercel.com: brings its fonts and colours, namespaced so your own theme stays untouched.
npx shadcn@latest add https://yoink-app.fly.dev/r/monochrome-precision/mine/industry-filter-select.json
Restyled to your project: uses your shadcn colours, fonts and radius, so it matches the rest of your app. Layout, type sizes and motion stay as designed.
Usage
Props: heading, options (string[]), defaultValue, onChange(value). Click or use arrow keys/Enter/Escape to open and choose from the listbox; hover fills #f2f2f2.
components/industry-filter-select.tsx
import { useState, useRef, useEffect } from "react"; export default function PillSelectFilter({ heading = "Loved by modern builders", options = ["All industries", "Finance", "Health", "Retail", "Software", "Media"], defaultValue = "All industries", onChange, }: { heading?: string; options?: string[]; defaultValue?: string; onChange?: (v: string) => void; }) { const [open, setOpen] = useState(false); const [value, setValue] = useState(defaultValue); const [active, setActive] = useState(0); const ref = useRef<HTMLDivElement>(null); useEffect(() => { const h = (e: MouseEvent) => { if (ref.current && !ref.current.contains(e.target as Node)) setOpen(false); }; document.addEventListener("mousedown", h); return () => document.removeEventListener("mousedown", h); }, []); const pick = (o: string) => { setValue(o); setOpen(false); onChange?.(o); }; const onKey = (e: React.KeyboardEvent) => { if (e.key === "ArrowDown") { e.preventDefault(); setOpen(true); setActive((a) => Math.min(a + 1, options.length - 1)); } else if (e.key === "ArrowUp") { e.preventDefault(); setActive((a) => Math.max(a - 1, 0)); } else if (e.key === "Enter" && open) { e.preventDefault(); pick(options[active]); } else if (e.key === "Escape") setOpen(false); }; return ( <div className="flex w-full items-center justify-between gap-6 bg-canvas px-6 py-10"> <h2 className="font-sans text-4xl font-medium tracking-[-0.04em] text-ink md:text-6xl">{heading}</h2> <div ref={ref} className="relative shrink-0"> <button type="button" aria-haspopup="listbox" aria-expanded={open} onClick={() => setOpen((o) => !o)} onKeyDown={onKey} className="inline-flex h-9 min-w-[10.5rem] items-center justify-between gap-6 rounded-pill bg-surface px-3 text-ui text-ink shadow-ring outline-none transition-colors duration-150 ease-[cubic-bezier(0.4,0,0.2,1)] hover:bg-[#f2f2f2] focus-visible:ring-2 focus-visible:ring-link-blue" > <span className="text-sm">{value}</span> <svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" className={`text-tertiary transition-transform ${open ? "rotate-180" : ""}`} aria-hidden="true"> <path d="M4 6l4 4 4-4" /> </svg> </button> {open && ( <ul role="listbox" className="absolute right-0 z-10 mt-2 w-full min-w-[10.5rem] rounded-xl bg-surface p-1 shadow-float ring-1 ring-hairline"> {options.map((o, i) => ( <li key={o} role="option" aria-selected={o === value} onMouseEnter={() => setActive(i)} onClick={() => pick(o)} className={`cursor-pointer rounded-md px-3 py-2 text-sm transition-colors duration-150 ${i === active ? "bg-[#f2f2f2]" : ""} ${o === value ? "text-ink" : "text-secondary"}`} > {o} </li> ))} </ul> )} </div> </div> ); }import { useState, useRef, useEffect } from "react"; export default function PillSelectFilter({ heading = "Loved by modern builders", options = ["All industries", "Finance", "Health", "Retail", "Software", "Media"], defaultValue = "All industries", onChange, }: { heading?: string; options?: string[]; defaultValue?: string; onChange?: (v: string) => void; }) { const [open, setOpen] = useState(false); const [value, setValue] = useState(defaultValue); const [active, setActive] = useState(0); const ref = useRef<HTMLDivElement>(null); useEffect(() => { const h = (e: MouseEvent) => { if (ref.current && !ref.current.contains(e.target as Node)) setOpen(false); }; document.addEventListener("mousedown", h); return () => document.removeEventListener("mousedown", h); }, []); const pick = (o: string) => { setValue(o); setOpen(false); onChange?.(o); }; const onKey = (e: React.KeyboardEvent) => { if (e.key === "ArrowDown") { e.preventDefault(); setOpen(true); setActive((a) => Math.min(a + 1, options.length - 1)); } else if (e.key === "ArrowUp") { e.preventDefault(); setActive((a) => Math.max(a - 1, 0)); } else if (e.key === "Enter" && open) { e.preventDefault(); pick(options[active]); } else if (e.key === "Escape") setOpen(false); }; return ( <div className="flex w-full items-center justify-between gap-6 bg-background px-6 py-10"> <h2 className="font-sans text-4xl font-medium tracking-[-0.04em] text-foreground md:text-6xl">{heading}</h2> <div ref={ref} className="relative shrink-0"> <button type="button" aria-haspopup="listbox" aria-expanded={open} onClick={() => setOpen((o) => !o)} onKeyDown={onKey} className="inline-flex h-9 min-w-[10.5rem] items-center justify-between gap-6 rounded-full bg-card px-3 text-monochrome-ui text-foreground shadow-monochrome-ring outline-none transition-colors duration-150 ease-[cubic-bezier(0.4,0,0.2,1)] hover:bg-secondary focus-visible:ring-2 focus-visible:ring-primary" > <span className="text-sm">{value}</span> <svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" className={`text-muted-foreground transition-transform ${open ? "rotate-180" : ""}`} aria-hidden="true"> <path d="M4 6l4 4 4-4" /> </svg> </button> {open && ( <ul role="listbox" className="absolute right-0 z-10 mt-2 w-full min-w-[10.5rem] rounded-2xl bg-card p-1 shadow-monochrome-float ring-1 ring-border"> {options.map((o, i) => ( <li key={o} role="option" aria-selected={o === value} onMouseEnter={() => setActive(i)} onClick={() => pick(o)} className={`cursor-pointer rounded-md px-3 py-2 text-sm transition-colors duration-150 ${i === active ? "bg-secondary" : ""} ${o === value ? "text-foreground" : "text-muted-foreground"}`} > {o} </li> ))} </ul> )} </div> </div> ); }
Quality checks
Automated, in a real browser · 4d ago- Accessible: passedNo serious accessibility problems (axe-core): readable contrast, labelled buttons and images.
- Responsive: passedRenders at phone (390px), tablet (768px) and desktop width without sideways scrolling.
- Dark mode: passedStill readable when installed in your theme and switched to dark mode.
- Themeable: passedUses design tokens rather than hard-coded colours, so it follows your theme cleanly.
- Animates cleanly: doesn't applyDoesn't animate, so there's nothing to check.