Skip to the main content

Button Group and Icon Buttons

Free Buttons

A segmented radio control, joined buttons, icon-only buttons with accessible names and a split button whose menu is a native popover.

Checked on 3 December 2026 in Chrome 143.0.7499.169: 12 automated checks. What the checks are

Preview and code

HTML

<section class="bg" aria-labelledby="bg-title">
  <h2 class="bg__title" id="bg-title">Button groups</h2>
  <p class="bg__lede">Segmented choices, joined buttons, icon buttons with names and a split button whose menu is a native popover.</p>

  <div class="bg__blocks">
  <div class="bg__block">
    <p class="bg__label" id="bg-seg-label">Segmented control</p>
    <div class="bg__seg" role="radiogroup" aria-labelledby="bg-seg-label">
      <label class="bg__seg-opt"><input class="bg__seg-input" type="radio" name="bg-range" value="day" checked><span>Day</span></label>
      <label class="bg__seg-opt"><input class="bg__seg-input" type="radio" name="bg-range" value="week"><span>Week</span></label>
      <label class="bg__seg-opt"><input class="bg__seg-input" type="radio" name="bg-range" value="month"><span>Month</span></label>
    </div>
  </div>

  <div class="bg__block">
    <p class="bg__label" id="bg-join-label">Joined buttons</p>
    <div class="bg__join" role="group" aria-labelledby="bg-join-label">
      <button class="bg__btn" type="button"><svg viewBox="0 0 20 20" width="16" height="16" aria-hidden="true" focusable="false"><path d="M12 4l-6 6 6 6" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/></svg>Previous</button>
      <button class="bg__btn" type="button">Today</button>
      <button class="bg__btn" type="button">Next<svg viewBox="0 0 20 20" width="16" height="16" aria-hidden="true" focusable="false"><path d="M8 4l6 6-6 6" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/></svg></button>
    </div>
  </div>

  <div class="bg__block">
    <p class="bg__label" id="bg-icon-label">Icon buttons</p>
    <div class="bg__icons" role="group" aria-labelledby="bg-icon-label">
      <button class="bg__icon" type="button" aria-label="Edit" data-tip="Edit"><svg viewBox="0 0 20 20" width="20" height="20" aria-hidden="true" focusable="false"><path d="M4 16l1-4 8-8 3 3-8 8z" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round"/></svg></button>
      <button class="bg__icon" type="button" aria-label="Duplicate" data-tip="Duplicate"><svg viewBox="0 0 20 20" width="20" height="20" aria-hidden="true" focusable="false"><rect x="7" y="7" width="9" height="9" rx="2" fill="none" stroke="currentColor" stroke-width="1.8"/><path d="M13 4H6a2 2 0 0 0-2 2v7" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg></button>
      <button class="bg__icon" type="button" aria-label="Download" data-tip="Download"><svg viewBox="0 0 20 20" width="20" height="20" aria-hidden="true" focusable="false"><path d="M10 3v9m-4-3.5l4 4 4-4M4 16h12" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg></button>
      <button class="bg__icon bg__icon--danger" type="button" aria-label="Delete" data-tip="Delete"><svg viewBox="0 0 20 20" width="20" height="20" aria-hidden="true" focusable="false"><path d="M4 6h12M8 6V4h4v2m-6 0l.7 10h6.6L14 6" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg></button>
    </div>
  </div>

  <div class="bg__block">
    <p class="bg__label" id="bg-split-label">Split button</p>
    <div class="bg__split" role="group" aria-labelledby="bg-split-label">
      <button class="bg__main" type="button">Save draft</button>
      <button class="bg__more" type="button" popovertarget="bg-menu" aria-label="More save options"><svg viewBox="0 0 20 20" width="16" height="16" aria-hidden="true" focusable="false"><path d="M5 8l5 5 5-5" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/></svg></button>
      <div class="bg__menu" id="bg-menu" popover>
        <button class="bg__item" type="button">Save and close</button>
        <button class="bg__item" type="button">Save as a copy</button>
        <button class="bg__item bg__item--danger" type="button">Discard changes</button>
      </div>
    </div>
  </div>
  </div>
</section>

CSS

.bg {
  --bg-surface: #ffffff;
  --bg-ink: #1f2430;
  --bg-muted: #525b6e;
  --bg-line: #d9deea;
  --bg-border: #6b7487;
  --bg-wash: #f1f3f9;
  --bg-accent: #bf3a0c;
  --bg-accent-ink: #ffffff;
  --bg-danger: #a8182f;
  --bg-ring: #1f2430;
  box-sizing: border-box;
  container-type: inline-size;
  width: min(100%, 40rem);
  padding: 1.5rem;
  color: var(--bg-ink);
  background: var(--bg-surface);
  border: 1px solid var(--bg-line);
  border-radius: 18px;
  box-shadow: 0 1px 2px rgb(31 36 48 / 6%), 0 14px 32px -14px rgb(31 36 48 / 24%);
  font: 1rem/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.bg *, .bg *::before, .bg *::after { box-sizing: border-box; }
.bg__title { margin: 0; font-size: 1.35rem; line-height: 1.25; }
.bg__lede { margin: 0.35rem 0 1rem; max-width: 30rem; font-size: 0.9rem; color: var(--bg-muted); }
.bg__blocks { display: grid; gap: 1.25rem 2rem; }
.bg__block { min-width: 0; }
.bg__label { margin: 0 0 0.45rem; font-size: 0.75rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--bg-muted); }

.bg__seg { display: inline-flex; padding: 4px; gap: 2px; background: var(--bg-wash); border-radius: 12px; }
.bg__seg-opt { position: relative; display: inline-block; }
.bg__seg-input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; appearance: none; background: transparent; border-radius: 9px; cursor: pointer; }
.bg__seg-opt span { position: relative; display: block; min-width: 5rem; padding: 0.55rem 1rem; text-align: center; font-weight: 700; color: var(--bg-muted); pointer-events: none; }
.bg__seg-input:checked { background: var(--bg-surface); box-shadow: 0 1px 3px rgb(31 36 48 / 25%); }
.bg__seg-input:checked + span { color: var(--bg-ink); }

.bg__join { display: inline-flex; }
.bg__btn { display: inline-flex; align-items: center; gap: 0.4rem; min-height: 44px; padding: 0 1rem; font: inherit; font-weight: 700; color: var(--bg-ink); background: var(--bg-surface); border: 1.5px solid var(--bg-border); cursor: pointer; }
.bg__btn + .bg__btn { margin-left: -1.5px; }
.bg__btn:first-child { border-radius: 10px 0 0 10px; }
.bg__btn:last-child { border-radius: 0 10px 10px 0; }
.bg__btn:hover { background: var(--bg-wash); }
.bg__btn:focus-visible { position: relative; z-index: 1; }

.bg__icons { display: inline-flex; gap: 0.4rem; }
.bg__icon { position: relative; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; color: var(--bg-ink); background: var(--bg-wash); border: 0; border-radius: 12px; cursor: pointer; }
.bg__icon:hover { background: var(--bg-line); }
.bg__icon--danger { color: var(--bg-danger); }
.bg__icon::after { content: attr(data-tip); position: absolute; top: calc(100% + 6px); left: 50%; z-index: 2; padding: 0.2rem 0.55rem; font-size: 0.75rem; font-weight: 700; color: var(--bg-surface); background: var(--bg-ink); border-radius: 6px; white-space: nowrap; transform: translateX(-50%); opacity: 0; pointer-events: none; transition: opacity 0.12s ease; }
.bg__icon:hover::after, .bg__icon:focus-visible::after { opacity: 1; }

.bg__split { position: relative; display: inline-flex; anchor-name: --bg-split; }
.bg__main, .bg__more { min-height: 44px; font: inherit; font-weight: 700; color: var(--bg-accent-ink); background: var(--bg-accent); border: 0; cursor: pointer; }
.bg__main { padding: 0 1.1rem; border-radius: 10px 0 0 10px; }
.bg__more { display: grid; place-items: center; width: 44px; margin-left: 1px; border-radius: 0 10px 10px 0; }
.bg__main:hover, .bg__more:hover { filter: brightness(1.1); }
.bg__menu { margin: 0; padding: 0.35rem; color: var(--bg-ink); background: var(--bg-surface); border: 1px solid var(--bg-line); border-radius: 12px; box-shadow: 0 12px 30px -8px rgb(31 36 48 / 40%); min-width: 12rem; }
.bg__menu:popover-open { display: grid; gap: 2px; }
.bg__item { min-height: 44px; padding: 0 0.8rem; font: inherit; font-weight: 600; text-align: left; color: var(--bg-ink); background: transparent; border: 0; border-radius: 8px; cursor: pointer; }
.bg__item:hover { background: var(--bg-wash); }
.bg__item--danger { color: var(--bg-danger); }
@supports (anchor-name: --a) {
  .bg__menu { position: fixed; position-anchor: --bg-split; inset: auto; top: anchor(bottom); left: anchor(left); margin: 6px 0; position-try-fallbacks: flip-block; }
}
.bg__seg-input:focus-visible, .bg__btn:focus-visible, .bg__icon:focus-visible, .bg__main:focus-visible, .bg__more:focus-visible, .bg__item:focus-visible { outline: 3px solid var(--bg-ring); outline-offset: 2px; }
@container (min-width: 32rem) {
  .bg__blocks { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 26rem) {
  .bg { padding: 1rem; }
  .bg__seg-opt span { min-width: 4.2rem; padding-inline: 0.5rem; }
  .bg__btn { gap: 0.25rem; padding: 0 0.6rem; font-size: 0.9rem; }
}
@media (prefers-color-scheme: dark) {
  .bg {
    --bg-surface: #1a1e2b; --bg-ink: #eef0f8; --bg-muted: #aeb6cb; --bg-line: #323a52; --bg-border: #8a94ad; --bg-wash: #262c40;
    --bg-accent: #ff9a6b; --bg-accent-ink: #2a1004; --bg-danger: #ff93a3; --bg-ring: #eef0f8;
    box-shadow: 0 1px 2px rgb(0 0 0 / 35%), 0 16px 34px -14px rgb(0 0 0 / 70%);
  }
  .bg__menu { box-shadow: 0 12px 30px -8px rgb(0 0 0 / 70%); }
}
@media (prefers-reduced-motion: reduce) {
  .bg__icon::after { transition: none; }
}

Accessibility notes

Written by the author of the snippet. Each note has a test step or a markup check that reads the page.

  • Icon-only buttons have an aria-label, and the tooltip text repeats it for sighted users on hover and focus.
  • The split button chevron names itself and opens a popover with popovertarget, so Escape and focus return come from the browser.
  • The segmented control is a real radio group: arrow keys move the choice.