{
  "id": "search-recent-dropdown",
  "name": "Search with Recent Items",
  "category": "forms",
  "tags": [
    "search",
    "recent searches",
    "dropdown",
    "focus-within",
    "suggestions",
    "panel"
  ],
  "description": "A search field that opens a panel of recent searches while it has focus, using :focus-within and no JavaScript.",
  "url": "https://copy-css.com/snippets/search-recent-dropdown",
  "markdown": "https://copy-css.com/snippets/search-recent-dropdown.md",
  "html": "<form class=\"search-recent\" role=\"search\">\n  <label class=\"search-recent-sr\" for=\"search-recent-q\">Search</label>\n  <input id=\"search-recent-q\" type=\"search\" name=\"q\" placeholder=\"Search docs…\" autocomplete=\"off\">\n  <div class=\"search-recent-panel\">\n    <p>Recent</p>\n    <a href=\"#\">container queries</a>\n    <a href=\"#\">grid template areas</a>\n    <a href=\"#\">color-mix()</a>\n  </div>\n</form>",
  "css": ".search-recent {\n  position: relative;\n  width: 260px;\n  font-family: system-ui, sans-serif;\n}\n\n.search-recent-sr {\n  position: absolute;\n  width: 1px;\n  height: 1px;\n  overflow: hidden;\n  clip-path: inset(50%);\n  white-space: nowrap;\n}\n\n.search-recent input {\n  box-sizing: border-box;\n  width: 100%;\n  padding: 11px 14px 11px 40px;\n  border: 1.5px solid #e2e8f0;\n  border-radius: 12px;\n  background: #fff url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' 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 13px center / 17px;\n  color: #0f172a;\n  font: 15px system-ui, sans-serif;\n  outline: none;\n}\n\n.search-recent input:focus {\n  border-color: #6366f1;\n}\n\n.search-recent-panel {\n  position: absolute;\n  top: calc(100% + 6px);\n  right: 0;\n  left: 0;\n  z-index: 10;\n  display: grid;\n  padding: 6px;\n  border: 1px solid #e2e8f0;\n  border-radius: 12px;\n  background: #fff;\n  box-shadow: 0 16px 32px -12px rgba(15, 23, 42, 0.25);\n  opacity: 0;\n  visibility: hidden;\n  transform: translateY(-4px);\n  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;\n}\n\n.search-recent:focus-within .search-recent-panel {\n  opacity: 1;\n  visibility: visible;\n  transform: none;\n}\n\n.search-recent-panel p {\n  margin: 4px 8px;\n  color: #94a3b8;\n  font-size: 11px;\n  font-weight: 700;\n  text-transform: uppercase;\n}\n\n.search-recent-panel a {\n  padding: 7px 8px;\n  border-radius: 8px;\n  color: #334155;\n  font-size: 14px;\n  text-decoration: none;\n}\n\n.search-recent-panel a:hover,\n.search-recent-panel a:focus-visible {\n  background: #eef2ff;\n  color: #4338ca;\n  outline: none;\n}",
  "features": [
    "transitions",
    "transforms",
    "box shadows",
    "clip paths",
    "CSS Grid",
    "keyboard focus styles"
  ],
  "customProperties": []
}
