{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"navbar-with-search-field-and-category-bar","type":"registry:block","title":"Navbar with Search Field and Category Bar","description":"Store navbar with a pill search field and suggestions, a basket count and a scrolling category bar with underline. Free React and Tailwind code, or HTML.","dependencies":[],"files":[{"path":"components/we-inc/navbar-with-search-field-and-category-bar.tsx","type":"registry:component","content":"// Adapted from Meraki UI (https://merakiui.com/components)\n// Copyright (c) 2021 Khatab Wedaa. MIT License: https://we.inc/components/licenses\nimport { useState } from \"react\";\n\nconst cats = [\"All\", \"Kitchen\", \"Lighting\", \"Textiles\", \"Storage\", \"Outdoor\", \"Sale\"];\nconst catalogue = [\"Linen apron\", \"Oak spice rack\", \"Brass desk lamp\", \"Wool throw\", \"Stackable crate\", \"Garden trowel set\", \"Ceramic pour-over\", \"Cane pendant light\"];\n\nexport default function NavbarSearchCategories() {\n  const [cat, setCat] = useState(\"All\");\n  const [q, setQ] = useState(\"\");\n  const [focus, setFocus] = useState(false);\n  const hits = q ? catalogue.filter((c) => c.toLowerCase().includes(q.toLowerCase())).slice(0, 4) : [];\n  return (\n    <div className=\"min-h-[360px] bg-white\">\n      <header className=\"border-b border-slate-200\">\n        <div className=\"mx-auto flex max-w-6xl flex-wrap items-center gap-3 px-4 py-3 sm:px-6\">\n          <a href=\"#\" className=\"mr-2 text-lg font-bold tracking-tight text-slate-900 focus:outline-none focus-visible:ring-2 focus-visible:ring-orange-600\">Hearth<span className=\"text-orange-600\">&amp;</span>Co</a>\n          <div className=\"relative order-3 w-full sm:order-none sm:flex-1 sm:max-w-xl\">\n            <label htmlFor=\"nbs-q\" className=\"sr-only\">Search the shop</label>\n            <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" aria-hidden=\"true\" className=\"pointer-events-none absolute left-3.5 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-500\"><path d=\"m21 21-4.3-4.3M17 10a7 7 0 1 1-14 0 7 7 0 0 1 14 0Z\" /></svg>\n            <input id=\"nbs-q\" value={q} onChange={(e) => setQ(e.target.value)} onFocus={() => setFocus(true)} onBlur={() => setTimeout(() => setFocus(false), 120)} placeholder=\"Search for lamps, linen, crates\" className=\"h-11 w-full rounded-full border border-slate-300 bg-slate-50 pl-10 pr-4 text-sm text-slate-900 placeholder:text-slate-500 focus:border-orange-500 focus:bg-white focus:outline-none focus:ring-2 focus:ring-orange-500/25\" />\n            {focus && hits.length > 0 && (\n              <ul className=\"absolute left-0 right-0 z-10 mt-2 overflow-hidden rounded-xl bg-white py-1 shadow-xl ring-1 ring-slate-900/10\">\n                {hits.map((h) => (\n                  <li key={h}><a href=\"#\" className=\"block px-4 py-2.5 text-sm text-slate-800 hover:bg-orange-50\">{h}</a></li>\n                ))}\n              </ul>\n            )}\n          </div>\n          <div className=\"ml-auto flex items-center gap-1\">\n            <a href=\"#\" className=\"rounded-lg px-3 py-2 text-sm font-medium text-slate-700 hover:bg-slate-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-orange-600\">Sign in</a>\n            <a href=\"#\" aria-label=\"Basket, 2 items\" className=\"relative inline-flex h-10 w-10 items-center justify-center rounded-full text-slate-700 hover:bg-slate-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-orange-600\">\n              <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\" className=\"h-5 w-5\"><path d=\"M5 8h14l-1 12H6L5 8Zm4 0V6a3 3 0 0 1 6 0v2\" /></svg>\n              <span className=\"absolute -right-0.5 -top-0.5 inline-flex h-5 min-w-[1.25rem] items-center justify-center rounded-full bg-orange-600 px-1 text-xs font-bold text-white\">2</span>\n            </a>\n          </div>\n        </div>\n        <nav aria-label=\"Categories\" className=\"mx-auto max-w-6xl overflow-x-auto px-4 sm:px-6\">\n          <ul className=\"flex gap-1 whitespace-nowrap\">\n            {cats.map((c) => (\n              <li key={c}>\n                <button type=\"button\" aria-pressed={cat === c} onClick={() => setCat(c)} className={`relative min-h-[44px] px-3 text-sm font-medium transition focus:outline-none focus-visible:ring-2 focus-visible:ring-orange-600 ${cat === c ? \"text-orange-700\" : c === \"Sale\" ? \"text-rose-700 hover:text-rose-800\" : \"text-slate-700 hover:text-slate-900\"}`}>\n                  {c}\n                  {cat === c && <span className=\"absolute inset-x-3 bottom-0 h-0.5 rounded-full bg-orange-600\" />}\n                </button>\n              </li>\n            ))}\n          </ul>\n        </nav>\n      </header>\n      <div className=\"mx-auto grid max-w-6xl grid-cols-2 gap-4 px-6 py-8 sm:grid-cols-4\">\n        {catalogue.slice(0, 4).map((c, i) => (\n          <div key={c}><div className={`h-24 rounded-xl ${[\"bg-orange-100\", \"bg-amber-100\", \"bg-stone-200\", \"bg-rose-100\"][i]}`} /><p className=\"mt-2 text-sm font-medium text-slate-800\">{c}</p><p className=\"text-sm text-slate-600\">Showing {cat.toLowerCase()}</p></div>\n        ))}\n      </div>\n    </div>\n  );\n}\n"}]}
