{
  "id": "command-search-bar",
  "name": "Command Search Bar",
  "category": "forms",
  "tags": [
    "search",
    "command palette",
    "keyboard shortcut",
    "kbd",
    "cmd k",
    "docs"
  ],
  "description": "A docs-style search bar with a ⌘K shortcut hint that hides itself once you focus the field or start typing.",
  "url": "https://copy-css.com/snippets/command-search-bar",
  "markdown": "https://copy-css.com/snippets/command-search-bar.md",
  "html": "<form class=\"cmd-search\" role=\"search\">\n  <input type=\"search\" name=\"q\" placeholder=\"Search…\" aria-label=\"Search\" aria-keyshortcuts=\"Meta+K\">\n  <kbd aria-hidden=\"true\">⌘K</kbd>\n</form>",
  "css": ".cmd-search {\n  position: relative;\n  width: 240px;\n  font-family: system-ui, sans-serif;\n}\n\n.cmd-search input {\n  box-sizing: border-box;\n  width: 100%;\n  padding: 9px 52px 9px 36px;\n  border: 1px solid #3f3f46;\n  border-radius: 10px;\n  background: #27272a url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E\") no-repeat 11px center / 16px;\n  color: #fafafa;\n  font: 14px system-ui, sans-serif;\n  outline: none;\n  transition: border-color 0.2s ease, background-color 0.2s ease;\n}\n\n.cmd-search input::placeholder {\n  color: #a1a1aa;\n}\n\n.cmd-search input:hover {\n  border-color: #52525b;\n}\n\n.cmd-search input:focus-visible {\n  border-color: #a78bfa;\n  background-color: #18181b;\n  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.25);\n}\n\n.cmd-search kbd {\n  position: absolute;\n  top: 50%;\n  right: 8px;\n  padding: 2px 6px;\n  border: 1px solid #52525b;\n  border-radius: 6px;\n  color: #a1a1aa;\n  font: 600 11px system-ui, sans-serif;\n  pointer-events: none;\n  transform: translateY(-50%);\n  transition: opacity 0.15s ease;\n}\n\n.cmd-search input:focus ~ kbd,\n.cmd-search input:not(:placeholder-shown) ~ kbd {\n  opacity: 0;\n}",
  "features": [
    "transitions",
    "transforms",
    "box shadows",
    "keyboard focus styles"
  ],
  "customProperties": []
}
