Expand-to-Label Icon
A compact icon button widens to reveal its action label without occupying permanent space.
A compact icon button widens to reveal its action label without occupying permanent space.
Live Demo
Hover over the element or use Tab to focus.
Source Code
Copy the HTML, CSS or JavaScript you need for your project.
<div class="tbx-1227"><button class="tbx-1227-action" type="button" aria-label="Save to collection (demo)"><span class="tbx-1227-icon" aria-hidden="true">☆</span><span class="tbx-1227-text">Save to collection</span></button></div>
.tbx-1227{box-sizing:border-box;max-width:100%;overflow:visible}
.tbx-1227{display:grid;place-items:center;min-height:200px;width:100%;padding:20px;background:#eae6f5;font-family:Arial,sans-serif}.tbx-1227 *{box-sizing:border-box}.tbx-1227-action{display:flex;align-items:center;justify-content:center;gap:11px;width:55px;height:55px;min-width:0;padding:0 16px;border:2px solid #65509d;border-radius:40px;background:#fff;color:#544080;cursor:pointer;overflow:hidden;white-space:nowrap;box-shadow:0 6px 16px #5e479d21;transition:width .47s,background .33s,color .33s}.tbx-1227-icon{flex:0 0 auto;font-size:25px;line-height:1;transition:transform .45s}.tbx-1227-text{width:0;flex:0 0 auto;overflow:hidden;font-size:12px;font-weight:800;opacity:0;transition:width .4s,opacity .3s}.tbx-1227-action:is(:hover,:focus-visible){width:210px;justify-content:flex-start;background:#65509d;color:#fff}.tbx-1227-action:is(:hover,:focus-visible) .tbx-1227-icon{transform:rotate(-15deg)}.tbx-1227-action:is(:hover,:focus-visible) .tbx-1227-text{width:135px;opacity:1}.tbx-1227-action:focus-visible{outline:3px solid #3a2767;outline-offset:5px}
@media(prefers-reduced-motion:reduce){.tbx-1227 *, .tbx-1227 *::before,.tbx-1227 *::after{transition:none !important;animation:none !important;scroll-behavior:auto !important}}
How to Use
Insert the HTML and add the CSS to your stylesheet. Adjust colors and sizes and avoid class conflicts.
Use Case
Useful for navigation menus and utility sections.
Technical Notes
Keep controls usable on touch devices. Test keyboard focus and reduced-motion preferences.
Mobile: Ensure the interactive content remains accessible without hover on touch devices.
Browser: Uses modern CSS. Check behavior in the browsers you support.
Reduced Motion: Check that prefers-reduced-motion is respected.