---
title: "Taskbar"
description: "Taskbar component - the bar along a desktop's edge: a Start Button, launchers, one button per open window rendered from the Window Manager (pressed for the one in front, a click brings it forward or minimizes it) and a Tray; any edge, centred or not."
slug: "taskbar"
---

import { DocPage, PageHeader, SkillPanel, SourceFiles, SourceNote, StatesSection, ApiSection, DocLink, SkillField, SkillText, SkillRow, ApiPill } from "../../lib/components/index";

<DocPage meta={meta}>

<PageHeader slug="taskbar" title="Taskbar" component="taskbar">
  The bar along a desktop's edge. It holds a <DocLink href="start-button.html">Start Button</DocLink>, buttons of the page's own (launchers), one button per open window and a <DocLink href="tray.html">Tray</DocLink>. The window buttons are the <DocLink href="window-manager.html">Window Manager</DocLink>'s model, rendered on every change: pressed for the window in front, a click brings a window to the front, minimizes the one in front or brings a minimized one back. Bound to a taskbar, the manager hides minimized windows - they live on their buttons. The bar sits on any edge and lines its buttons up from the start or in the middle; a <code>.desktop</code> wrapper lays the window area out beside it.
</PageHeader>

<SkillPanel component="taskbar">
  <SkillField label="Native basis">
<SkillText>A <code>&lt;nav&gt;</code> of buttons. <code>data-taskbar-for</code> names the Window Manager; the runtime renders <code>button.taskbar-window</code>s into <code>.taskbar-windows</code> from its <code>window-manager-change</code> event. Everything else is authored.</SkillText>
  </SkillField>

  <SkillField label="Web Platform APIs">
<SkillRow>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent" title="the manager's model arrives as an event"><code>CustomEvent</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-pressed" title="the window in front"><code>aria-pressed</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/CSS/:has" title="the desktop wrapper follows the bar's edge"><code>:has()</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter" title="the translucent bar"><code>backdrop-filter</code></ApiPill>
  </SkillRow>
  </SkillField>

  <SkillField label="Variants">
<SkillText dense>• <code>data-position="top|left|right"</code> - the edge (default bottom); left and right make a column with icon-only window buttons.</SkillText>
  <SkillText dense>• <code>data-align="center"</code> - Start, launchers and windows centred; the Tray stays at the end.</SkillText>
  </SkillField>
</SkillPanel>

```html example label="A desktop" hint="Window Manager, Desktop Manager, Taskbar, Start Button, Start Menu and Tray together. Double-click an icon or pick an app from Start: its window opens and gets a button. Click a button to bring its window forward, again to minimize it. The strip at the far right shows the desktop."
<div class="grid gap-2">
  <label class="flex items-center gap-2 text-sm"
    >Look
    <select class="select" data-look style="width: auto">
      <option value="">Modern</option>
      <option value="win7">7</option>
      <option value="winxp">XP</option>
      <option value="win98">98</option>
      <option value="win95">95</option>
    </select></label
  >

  <div class="desktop" style="height: 26rem; border-radius: var(--radius-lg)">
    <div
      class="window-desktop window-manager"
      id="tb-desk"
      style="--desktop-wallpaper: linear-gradient(160deg, oklch(0.55 0.1 240), oklch(0.35 0.08 200))"
    >
      <div
        class="desktop-manager"
        id="tb-icons"
        data-on-wallpaper
        role="listbox"
        aria-multiselectable="true"
        aria-label="Desktop"
      >
        <div class="desktop-icon" role="option" data-value="tb-notes">
          <span class="desktop-icon-image"><span class="desktop-glyph" data-glyph="text"></span></span>
          <span class="desktop-icon-label">Notes</span>
        </div>
        <div class="desktop-icon" role="option" data-value="tb-files">
          <span class="desktop-icon-image"><span class="desktop-glyph" data-glyph="folder"></span></span>
          <span class="desktop-icon-label">Files</span>
        </div>
        <div class="desktop-icon" role="option" data-value="tb-calc">
          <span class="desktop-icon-image"><span class="desktop-glyph" data-glyph="calculator"></span></span>
          <span class="desktop-icon-label">Calculator</span>
        </div>
      </div>
      <dialog class="window" id="tb-notes" open style="--window-x: 8rem; --window-y: 1.5rem; --window-w: 17rem">
        <header class="window-titlebar">
          <span class="window-icon desktop-glyph" data-glyph="text"></span>
          <h2 class="window-title">Notes</h2>
          <form method="dialog" class="window-controls">
            <button type="button" class="window-minimize" aria-label="Minimize"></button>
            <button type="button" class="window-maximize" aria-label="Maximize"></button>
            <button class="window-close" aria-label="Close"></button>
          </form>
        </header>
        <div class="window-body"><textarea class="textarea" aria-label="Note">Buy milk</textarea></div>
      </dialog>
      <dialog class="window" id="tb-files" style="--window-x: 14rem; --window-y: 4rem; --window-w: 16rem">
        <header class="window-titlebar">
          <span class="window-icon desktop-glyph" data-glyph="folder"></span>
          <h2 class="window-title">Files</h2>
          <form method="dialog" class="window-controls">
            <button type="button" class="window-minimize" aria-label="Minimize"></button>
            <button type="button" class="window-maximize" aria-label="Maximize"></button>
            <button class="window-close" aria-label="Close"></button>
          </form>
        </header>
        <div class="window-body">Documents, Pictures, Music</div>
      </dialog>
      <dialog class="window" id="tb-calc" style="--window-x: 20rem; --window-y: 2rem; --window-w: 12rem">
        <header class="window-titlebar">
          <span class="window-icon desktop-glyph" data-glyph="calculator"></span>
          <h2 class="window-title">Calculator</h2>
          <form method="dialog" class="window-controls">
            <button type="button" class="window-minimize" aria-label="Minimize"></button>
            <button class="window-close" aria-label="Close"></button>
          </form>
        </header>
        <div class="window-body">0</div>
      </dialog>
    </div>
    <nav class="taskbar" id="tb-bar" data-state-demo data-taskbar-for="tb-desk" aria-label="Taskbar">
      <button class="start-button" type="button" popovertarget="tb-start" aria-haspopup="menu">
        <span class="start-button-icon desktop-glyph" data-glyph="flag"></span>
        <span class="start-button-label">Start</span>
      </button>
      <div class="taskbar-windows" role="group" aria-label="Open windows"></div>
      <div class="tray" role="group" aria-label="Notification area">
        <button class="tray-item" type="button" aria-label="Network"><i data-lucide="wifi"></i></button>
        <button class="tray-item" type="button" aria-label="Volume"><i data-lucide="volume-2"></i></button>
        <time class="tray-clock"></time>
        <button class="tray-show-desktop" type="button" aria-label="Show desktop"></button>
      </div>
    </nav>
    <div class="start-menu" id="tb-start" popover aria-label="Start">
      <label class="start-menu-search">
        <i data-lucide="search"></i>
        <input type="search" placeholder="Search apps" aria-label="Search apps" />
      </label>
      <div class="start-menu-list" role="group" aria-label="All apps">
        <button class="start-menu-item" type="button" data-value="tb-notes">
          <span class="start-menu-icon"><span class="desktop-glyph" data-glyph="text"></span></span>
          <span class="start-menu-label">Notes</span>
        </button>
        <button class="start-menu-item" type="button" data-value="tb-files">
          <span class="start-menu-icon"><span class="desktop-glyph" data-glyph="folder"></span></span>
          <span class="start-menu-label">Files</span>
        </button>
        <button class="start-menu-item" type="button" data-value="tb-calc">
          <span class="start-menu-icon"><span class="desktop-glyph" data-glyph="calculator"></span></span>
          <span class="start-menu-label">Calculator</span>
        </button>
      </div>
    </div>
  </div>
</div>
<script>
  document.addEventListener('DOMContentLoaded', () => {
    const open = (id) => df$.shadcn.win.open(id);
    document.querySelector('#tb-icons').addEventListener('desktop-open', (e) => e.detail.values.forEach(open));
    document.querySelector('#tb-start').addEventListener('start-select', (e) => open(e.detail.value));
  });
</script>
<script>
  // the Look select: the .desktop next to it takes the period's look
  document.addEventListener('DOMContentLoaded', () => {
    const select = document.querySelector('[data-look]');
    const desk = select.closest('.grid').querySelector('.desktop');
    select.addEventListener('change', () => {
      if (select.value) desk.dataset.variant = select.value;
      else delete desk.dataset.variant;
    });
  });
</script>
```

```html example label="Edges and centring" hint="The same bar on the left edge (a column of icon buttons) and centred at the bottom - the Start Button moves with the window buttons, the Tray stays at the end."
<div class="grid gap-3" style="grid-template-columns: 1fr 1fr">
  <div class="desktop" style="height: 12rem; min-height: 0; border-radius: var(--radius-md)">
    <div class="window-desktop window-manager" id="tb-desk-l">
      <dialog class="window" open style="--window-x: 0.75rem; --window-y: 0.75rem; --window-w: 9rem">
        <header class="window-titlebar"
          ><span class="window-icon desktop-glyph" data-glyph="mail"></span><h2 class="window-title">Mail</h2></header
        >
        <div class="window-body">Inbox</div>
      </dialog>
    </div>
    <nav class="taskbar" data-taskbar-for="tb-desk-l" data-position="left" aria-label="Taskbar on the left">
      <button class="start-button" data-variant="icon" type="button" aria-haspopup="menu">
        <span class="start-button-icon desktop-glyph" data-glyph="flag"></span>
        <span class="start-button-label">Start</span>
      </button>
      <div class="taskbar-windows" role="group" aria-label="Open windows"></div>
    </nav>
  </div>
  <div class="desktop" style="height: 12rem; min-height: 0; border-radius: var(--radius-md)">
    <div class="window-desktop window-manager" id="tb-desk-c">
      <dialog class="window" open style="--window-x: 0.75rem; --window-y: 0.75rem; --window-w: 9rem">
        <header class="window-titlebar"
          ><span class="window-icon desktop-glyph" data-glyph="music"></span><h2 class="window-title">Music</h2></header
        >
        <div class="window-body">Playing</div>
      </dialog>
    </div>
    <nav class="taskbar" data-taskbar-for="tb-desk-c" data-align="center" aria-label="Centred taskbar">
      <button class="start-button" data-variant="icon" type="button" aria-haspopup="menu">
        <span class="start-button-icon desktop-glyph" data-glyph="flag"></span>
        <span class="start-button-label">Start</span>
      </button>
      <div class="taskbar-windows" role="group" aria-label="Open windows"></div>
      <div class="tray" role="group" aria-label="Notification area"><time class="tray-clock"></time></div>
    </nav>
  </div>
</div>
```

<StatesSection>
  <p class="text-sm text-muted-foreground m-0 mb-3">Named states via the shared State API, bound on each <code>.taskbar</code>:</p>
  <ul class="text-sm text-muted-foreground m-0 mb-3 ps-5">
    <li><code>default</code> - the bar; <code>\{ position, align \}</code> move it to an edge and line its buttons up</li>
  </ul>
  <p class="text-sm text-muted-foreground">The first example carries <code>data-state-demo</code>; <code>bun run screenshots</code> drives it via <code>el.api.setState(name)</code> and captures <code>screenshots/\{mode\}/taskbar-\{state\}.png</code>.</p>

Machine contract - verified against <a class="link" href="../schemas/taskbar.schema.json"><code>taskbar.schema.json</code></a> by <code>bun run verify</code>:

```states
| State | Type | Values | Default | Description |
| --- | --- | --- | --- | --- |
```

</StatesSection>

<ApiSection component="taskbar" />

<SourceFiles component="taskbar" section="css" />

<SourceFiles component="taskbar" section="js">
  <SourceNote for="js">The window buttons are rendered from the Window Manager's <code>window-manager-change</code>; a click is <code>df$.shadcn.windowManager.toggle()</code>.</SourceNote>
</SourceFiles>

</DocPage>
