TipsBlocks Web Technique Library

PRACTICAL WEB TIP

← Back to library

Navigation Focus Pill

A rounded highlight expands behind a navigation label to give the active link gentle emphasis.

Live Demo

Hover over the element or use Tab to focus.

Source Code

Copy the HTML, CSS or JavaScript you need for your project.

HTML
<button class="tbx-1024" type="button"><span>Services overview</span></button>
CSS
.tbx-1024{position:relative;isolation:isolate;display:inline-flex;justify-content:center;align-items:center;min-width:160px;min-height:48px;padding:10px 18px;border:0;border-radius:40px;background:transparent;color:#21405b;font:700 14px/1.3 system-ui;cursor:pointer;transition:color .28s ease}
.tbx-1024::before{content:"";position:absolute;inset:0;border-radius:inherit;background:#c8e7ef;z-index:-1;opacity:0;transform:scale(.55);transition:opacity .28s ease,transform .28s ease}
.tbx-1024:is(:hover,:focus-visible)::before{opacity:1;transform:scale(1)}
.tbx-1024:focus-visible{outline:3px solid #7b65db;outline-offset:4px}
@media(prefers-reduced-motion:reduce){.tbx-1024,.tbx-1024::before{transition:none}}

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.

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.