{
  "id": "expanding-icon-button",
  "name": "Expanding Icon Button",
  "category": "buttons",
  "tags": [
    "reveal label",
    "compact",
    "circle",
    "width",
    "hover"
  ],
  "description": "A compact round icon button that slides open to reveal its text label on hover or focus.",
  "url": "https://copy-css.com/snippets/expanding-icon-button",
  "markdown": "https://copy-css.com/snippets/expanding-icon-button.md",
  "html": "<button class=\"btn-expand\">\n  <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M12 5v14M5 12h14\"/></svg>\n  <span class=\"btn-expand-label\">Add item</span>\n</button>",
  "css": ".btn-expand {\n  display: inline-flex;\n  align-items: center;\n  height: 48px;\n  padding: 0 13px;\n  border: 0;\n  border-radius: 999px;\n  background: #18181b;\n  color: #fff;\n  font: 600 15px/1 system-ui, sans-serif;\n  cursor: pointer;\n  transition: padding 0.35s ease;\n}\n\n.btn-expand svg {\n  flex: none;\n  width: 22px;\n  height: 22px;\n  fill: none;\n  stroke: currentColor;\n  stroke-width: 2.2;\n  stroke-linecap: round;\n}\n\n/* The label stays in the accessibility tree, it is only clipped */\n.btn-expand-label {\n  max-width: 0;\n  overflow: hidden;\n  white-space: nowrap;\n  opacity: 0;\n  transition: max-width 0.35s ease, margin 0.35s ease, opacity 0.2s ease;\n}\n\n.btn-expand:hover,\n.btn-expand:focus-visible {\n  padding-right: 20px;\n}\n\n.btn-expand:hover .btn-expand-label,\n.btn-expand:focus-visible .btn-expand-label {\n  max-width: 140px;\n  margin-left: 8px;\n  opacity: 1;\n}\n\n.btn-expand:focus-visible {\n  outline: 2px solid #18181b;\n  outline-offset: 3px;\n}",
  "features": [
    "transitions",
    "Flexbox",
    "keyboard focus styles"
  ],
  "customProperties": []
}
