Theme
Design your own
On this page (4)
Component Skill — components/start-button/component-skill.md

Native basis

A <button popovertarget="..." aria-haspopup="menu"> naming its Start Menu.

Web Platform APIs

popovertargetanchor positioningforced-colors

Variants (data-variant)

• icon - the icon only; the label stays for screen readers.

§In a taskbar, in every look

The Start Button at the start of a Taskbar; pick a look and it takes that period's shape - the round orb of 7, XP's green start, the bevelled Start of 98 and 95. Its pressed look follows aria-expanded while its menu is open.

§Icon only

data-variant='icon' keeps the label for assistive technology and shows the icon alone - the modern look's centred bar.

§States

CSS-only: one state.

  • default - the only state; its menu's open state is the Start Menu's (aria-expanded mirrors it)

§CSS view file

/* -- Start Button component ---------------------------------------
   The button that opens a Start Menu - a native popovertarget, no script of
   its own (the Start Menu anchors itself to it and keeps aria-expanded). An
   icon, a label or both; pressed while its menu is open. A look restyles it
   (a bevelled "Start", a green pill, a round orb). */
@layer components {
  .start-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    height: 2.5rem;
    min-width: 2.5rem;
    padding-inline: 0.625rem;
    border: 0;
    border-radius: var(--radius-md);
    background: none;
    color: inherit;
    font: inherit;
    font-weight: 600;
    cursor: default;
    &:hover {
      background: color-mix(in oklch, var(--accent) 70%, transparent);
    }
    &[aria-expanded="true"] {
      background: var(--accent);
      color: var(--accent-foreground);
    }
    &:focus-visible {
      outline: 2px solid var(--ring);
      outline-offset: -2px;
    }
    & > :is(svg, img, .start-button-icon) {
      width: 1.375rem;
      height: 1.375rem;
      flex: none;
    }
    /* icon only: the label stays for assistive technology */
    &[data-variant="icon"] .start-button-label {
      position: absolute;
      width: 1px;
      height: 1px;
      overflow: hidden;
      clip-path: inset(50%);
      white-space: nowrap;
    }
  }
  @media (forced-colors: active) {
    .start-button[aria-expanded="true"] {
      outline: 2px solid Highlight;
    }
  }
}

Comments, ideas or improvements? Edit this page's source on GitHub