Skip to main content
239

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Themes
Web docs
Actions

SelectionBar

Floats a bulk-action bar with a pluralized selected count, actions, and a clear button over a multi-select list.

Frameworks
Astro · React · Elements · Dioxus
Registry
lumen add SelectionBar
Interaction
Enhanced runtime
01

See it and copy it

Framework example

Choose Astro, React, Elements, or Dioxus to compare native usage against the shared visual output. Each example assumes the framework-level setup is already complete.

AstroCode target · live preview uses Astro

2 photos selected

View SelectionBar code

Framework usage

Switch targets to compare the adapter code. This live preview runs the Astro example. Before copying an example, complete the matching framework setup; React, Elements, and Dioxus use their own behavior APIs.Width controls resize the preview container. Resize your browser to test viewport breakpoints.
astro
---
import { Button, Checkbox, Label, SelectionBar, Stack } from '@santi020k/lumen-astro'

const photos = ['Harbor at dawn', 'Market street', 'Summit trail', 'Night ferry']
---

<div id="demo-selection" style="max-block-size: 16rem; overflow: auto; border: 1px solid hsl(var(--line)); border-radius: var(--ui-radius-lg); padding: 0.75rem;">
  <Stack gap="related">
    {photos.map((photo, index) => (
      <Label for={`demo-photo-${index}`}>
        <Checkbox checked={index < 2} id={`demo-photo-${index}`} name="photos" value={photo} />
        {photo}
      </Label>
    ))}
  </Stack>
  <SelectionBar
    id="demo-selection-bar"
    count={2}
    clearOnEscape
    label={{ one: '{count} photo selected', other: '{count} photos selected' }}
  >
    <Button size="sm" variant="outline">Download</Button>
    <Button size="sm" variant="destructive">Delete</Button>
  </SelectionBar>
</div>

<script>
  const container = document.getElementById('demo-selection')
  const bar = document.getElementById('demo-selection-bar')
  const boxes = (): HTMLInputElement[] => Array.from(container?.querySelectorAll<HTMLInputElement>('input[name="photos"]') ?? [])

  const update = (): void => {
    bar?.setAttribute('data-count', String(boxes().filter(box => box.checked).length))
  }

  container?.addEventListener('change', update)

  bar?.addEventListener('ui:selection-clear', () => {
    for (const box of boxes()) box.checked = false

    update()
  })
</script>
Edit SelectionBar in browser
02

Choose your target

Add this component

Choose the package for your runtime. All adapters share the Lumen stylesheet. Use the matching registry command when you want a local wrapper for that framework.

bash@santi020k/lumen-astro
pnpm add @santi020k/lumen-astro
bashAstro wrapper
lumen add SelectionBar

API reference

Lumen-specific props and runtime attributes for the Astro primitive. Use the framework differences above and the copyable examples for React composition and Elements attributes; the public adapter types define their supported contracts.

AttributeValuesDefaultDescription
countnumber0Number of selected items. At 0 the bar is hidden with the hidden attribute, so it leaves the accessibility tree. In Astro, update data-count on the root from your script.
labelstring | { zero?, one?, two?, few?, many?, other }"{count} selected"Count text. An object picks the form with Intl.PluralRules for the locale. {count} is the formatted count. Elements use label, label-one, label-other, and so on.
children / default slotactions-Bulk actions, usually small Buttons.
onClear / clearable() => void | boolean- / trueReact shows the clear button when onClear is set. Astro and Elements show it unless clearable is false, and dispatch ui:selection-clear.
clearOnEscapebooleanfalseEscape inside the bar clears the selection. Elements use clear-on-escape.
placement"container" | "viewport""container"container sticks to the bottom of the nearest scroll container. viewport pins the bar to the screen and reserves its own height in the flow, so place it after the list and the last items scroll clear of it. Both respect the bottom safe-area inset.
clearLabel, clearedLabel, regionLabelstring"Clear selection", "Selection cleared", "Selection actions"Clear button text, the announcement when the count returns to 0, and the action group name.
localestringdocument languageLocale for plural rules and number formatting.
class, classNamestring""Merges custom classes with the generated ui-* root classes.
...native attributesHTML attributes-Forwards standard attributes to the root element unless the component consumes them.

Customize SelectionBar

Start with semantic theme tokens and a class on the public component. Keep its accessible name, focus treatment, and interaction state intact.

cssScoped theme overrides
.product-selection-bar {
  --surface: 0 0% 100%;
  --ink: 220 20% 15%;
  --line: 220 15% 82%;
}

Apply product-selection-bar through Astro's class, React's className, or the custom element's class. Verify foreground and background contrast in both schemes.

HookValuesDefaultContract
class, classNamestring""Merges custom classes with the generated ui-* root classes.

Use the documented hooks above and adapter types when targeting component states. Theme guide · Accessibility verification scope

Keyboard interactions

Keyboard behavior provided by the Astro UIPrimitives runtime for this component.

KeyAction
TabMove through the actions and the clear button.
Escape in the barClear the selection when clearOnEscape is set.

Runtime events

CustomEvents dispatched by the Astro UIPrimitives runtime for this component.

EventTargetDetailWhen
ui:selection-clearSelectionBar root ([data-ui-selection-bar]){ count: number }The clear button is pressed, or Escape is pressed inside the bar with clear-on-escape. Clear your selection and set the count to 0.

Web docsFull catalog