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://justyoink.it/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.

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>
  );
}

Quality checks

Automated, in a real browser · 4d ago
—

More from Monochrome Precision

The whole style →

Ink and Ghost Button Pair

Buttons

Dashed Orbit Integration Ring

Animated graphics

Customer Story Index List

Lists

Centered Quote with Meta Row

Testimonials

Hairline Navigation Bar

Headers & nav bars

Floating Triangle Hero with Logo Strip

Heroes