Quick selector
A game’s d-pad gear cluster and the row it opens: hold a direction, flick to an item, let go to equip.
quick-selector/quick-selector.tsxHold ↑←→ to choose↓ draw bow
The live component, numbered part by part. Every measurement is read from it as it is drawn. Point at a row to outline its part, or at a part to find its row.
The choices it offers, each value drawn live and the default marked, with how to pick one.
When to use
- Swapping gear in the middle of play without pausing: a weapon, a shield, an ability, an arrow type, a few items per slot.
- A game where each d-pad direction (or arrow key) owns one slot, and the player holds it, flicks to an item and lets go.
- A HUD that has to say at a glance what is in hand, and only shows the full list while a direction is held.
- A slot that changes meaning with a stance: the sides read shield and weapon in melee, arrows (with their count) and bow with the bow drawn.
- Gear that wears out or runs down, where the row shows durability or a count next to each item.
When not to use
- A full inventory with dozens of items, sorting and descriptions. Use a paused inventory grid.
- Picking one of many options in an ordinary interface. Use a select, a menu or a segmented control.
- Spells or tools picked by direction from eight or more at once. Use a radial wheel.
- Abilities fired straight from a key, with no choice to make. Use an ability bar with cooldowns.
- A single on/off choice, such as drawing the bow on its own. Use a toggle or one button.
Hold, or tap and pick
- Hold a direction (an arrow key, or a press on a slot) and the row opens on the equipped item. Step with left and right, let go, and what is under the frame is equipped.
- Tap it (shorter than 260 ms) and the row stays open, for a keyboard or a touch screen. Then Enter, Space, a click or a tap on a tile equips, and Escape cancels.
- Holding with a pointer, moving over the tiles moves the frame; letting go equips.
- At the end of the list the frame nudges and stays put. The row doesn’t wrap.
Slots and stances
- Up holds the abilities. Left and right hold the shield and the weapon, or the arrows and the bow with the bow drawn. Down draws or puts the bow away.
- The five slots are fixed:
ability,weapon,shield,bowandarrow.itemssets each one’s list, in row order; a slot left out keeps the built-in list. - Art comes from the component’s own set (
icon).tintrecolours an item’s main shape for a variant, like a rune blade beside an iron sword. - Uncontrolled it keeps its own state. With
equippedorstanceit follows yours: update them fromonEquipandonStanceChange.
Counts and durability
countis for things that run out, like arrows. It shows as ×N on the tile and beside the HUD slot, firing (F) spends one, and at zero the HUD count turns red and firing does nothing.durabilityis uses left on gear, in a dark box on the tile. The component only shows it: wear it down in your game and pass the new number.- Abilities carry neither: they never run out.
Each one drawn with the component itself, used well or badly.
Most of the words are item names, read in a flash while the frame passes over them.
- Item names: a noun with at most one word before it, sentence case:
Iron sword,Fire arrow. They are drawn above the frame and read out by screen readers. - Variants share the noun and change the word before it (
Iron sword,Ember sword), with atintto match. - Numbers stay bare:
60arrows show as ×60, durability as22. No units or words beside them. - Slot names (Abilities, Weapons, Shields, Bows, Arrows) and the key legend are built in, in English; screen readers hear them as “Weapons: Iron sword”.
You can add this component with the shadcn CLI or by hand:
Into components/quick-selector of any React project, with no setup:
npx shadcn@latest add https://brunodelorence.com/r/quick-selector.json- Copy the component files
Copy these files into one folder of your project, keeping their relative imports together, or download them as a ZIP:
- Copy the media files
To the same paths under your project’s public folder:
/experiments/eventide/icons/trail-sword.webp/experiments/eventide/icons/wayfarer-blade.webp/experiments/eventide/icons/reed-spear.webp/experiments/eventide/icons/forester-axe.webp/experiments/eventide/icons/root-club.webp/experiments/eventide/icons/willow-bow.webp/experiments/eventide/icons/storm-bow.webp/experiments/eventide/icons/rivet-shield.webp/experiments/eventide/icons/willow-shield.webp/experiments/eventide/icons/sunwarden-shield.webp/experiments/eventide/icons/pulse-orb.webp/experiments/eventide/icons/reed-arrow.webp/experiments/eventide/icons/cinder-arrow.webp/experiments/eventide/icons/frost-arrow.webp/experiments/eventide/icons/storm-arrow.webp/experiments/eventide/icons/pulse-arrow.webp/experiments/eventide/icons/magnetic-knot.webp/experiments/eventide/icons/pulse-cube.webp/experiments/eventide/icons/time-anchor.webp/experiments/eventide/icons/frostwell.webp/experiments/eventide/icons/cinder-blade.webp/experiments/eventide/manifests/quick-selector.json
- Import it
As shown under Usage, below.
Either way it needs React 19 and a bundler that supports CSS Modules, such as Next.js or Vite. It has a dark colour scheme: it follows your page’s color-scheme, light unless the page sets one, or its colorScheme prop, with nothing to configure. Browsers without light-dark() show it light.
Usage
import { QuickSelector, type QuickCategory } from './quick-selector';export function GearHud({ gear, onEquip,}: { gear: Record<QuickCategory, string>; onEquip: (category: QuickCategory, id: string) => void;}) { return <QuickSelector bare equipped={gear} onEquip={onEquip} />;}Each state below is a live instance, locked so you can study it.
The pieces it is built from, each with its measurements read live.
How a game lets the player swap gear without stopping: a d-pad cluster on the HUD shows the ability, shield and weapon in hand (arrows and bow once the bow is drawn), and holding a direction opens that slot’s row above it. A cream frame steps from tile to tile with the item’s name above it, the row scrolls and fades at its ends, and letting go floods the tile blue and pops the new item into its slot. Hold the arrow keys, or press and hold a slot.
- The HUD is a zero-size box at the d-pad’s centre: the four dots sit 13 units around it, the ability 45 units above, the shield or arrows 36 to the left and the weapon or bow 31 to the right, each a button. Its glyphs are the equipped items drawn in white (the ability keeps its colour), with a soft drop shadow, as on a game’s HUD.
- Holding a slot (an arrow key, or a press on it) opens its row with the frame on the equipped item. Left and right (or A/D, Q/E) step the frame; letting go equips what is under it. A press shorter than 260 ms is a tap instead: the row stays open for Enter, a click or a tap on a tile, and Escape cancels. Down draws or puts away the bow, which turns the sides into arrows and bow; F fires an arrow and spends one.
- The row shows five tiles. The strip keeps the frame one tile off its ends while there is more beyond, moving by translate (180 ms); the end tile on a side with more items fades out through a mask whose stops are two registered custom properties, so the fade eases in and out.
- The frame, the name, its dot and the stick glyph travel together in one layer that glides 140 ms per step; the new item bumps to 1.1, the name rises in, and at the end of the list the frame nudges 6 units out and back (Web Animations). Opening raises the row 10 units as its tiles stagger in 22 ms apart.
- Equipping floods the chosen tile blue from 0.55, fades the row out in 150 ms, and remounts the slot’s glyph, which pops from 0.6 through 1.16 with a white flash; drawing the bow flips the side slots in, and each shot pulses the arrow count, red at zero.
- Sizes are in units of the kit’s art (a tile is 112), turned into pixels from the stage’s width by a container query: 1 px at full size, 0.4 px on a narrow phone. The HUD is drawn 1.3 times larger with a 0.62 px floor, so the d-pad stays readable and pressable.
- Original Eventide equipment and ability paintings share stable identities with the inventory and modal. The radial selection, tint variants, keyboard and gamepad controls remain live.
- Uncontrolled, it keeps its own gear and stance, and a demo plays a short run while it is on screen and untouched: a new weapon, the magnet, a bigger shield, the bow drawn, shots, fire arrows. Any real input hands it to the reader. equipped and stance control it; onEquip and onStanceChange report.
| Prop | Type | Default | Description |
|---|---|---|---|
items | Partial<Record<QuickCategory, QuickItem[]>> | DEFAULT_ITEMS | Each slot’s items in row order: { id, name, icon, tint?, count?, durability? }. icon names one of the component’s glyphs; count shows as ×N (arrows), durability in a dark box (gear). Categories: ability, weapon, shield, bow, arrow. |
equipped | Partial<Record<QuickCategory, string>> | — | The equipped item’s id in each slot, controlled. Pair it with onEquip. Turns the demo off. |
defaultEquipped | Partial<Record<QuickCategory, string>> | time lock, iron sword, iron shield, short bow, arrow | Uncontrolled, the items equipped at the start. |
onEquip | (category: QuickCategory, id: string) => void | — | Called when the player lets go on an item (or picks one in an open row). |
stance | 'melee' | 'ranged' | — | Controlled: melee shows shield and weapon on the sides, ranged shows arrows (with their count) and bow. Turns the demo off. |
onStanceChange | (stance: 'melee' | 'ranged') => void | — | Called when the player draws or puts away the bow (the d-pad’s down). |
bare | boolean | false | No key legend under it: the HUD and its row alone, to lay over a game of your own. |
autoplay | boolean | true | While on screen and untouched, a short run of play; real input stops it, and it never plays under reduced motion. |
defaultOpen | 'ability' | 'weapon' | 'shield' | 'bow' | 'arrow' | — | Starts with this slot’s row open, as if tapped (it stays open until an item is picked or Escape), for a still. Turns the demo off. |
defaultCursor | string | — | With defaultOpen, the id of the item the frame starts on; the equipped one when left out. |
colorScheme | 'light' | 'dark' | 'system' | — | Forces light or dark for the key chips and the tiles’ edges; without it, they follow the page. The disc, the pill and the tiles keep their own dark colours. |
className | string | — | Classes for the root, the stage. |
Keyboard
Tab reaches the slots, which are buttons; the keys then work anywhere inside the group. Hold an arrow key (up, left, right) to open its row, step with left and right (or A and D, Q and E), Home and End jump to the ends, and letting go equips. A quick press, or Enter or Space on a slot, leaves the row open: Enter or Space equips, Escape or Backspace cancels. Down draws or puts away the bow, F fires. Focus moves into the row as it opens and back to its slot as it closes.
Screen readers
- Each slot is a button named with its slot and item, “Weapons: Iron sword”, with
aria-haspopup="listbox",aria-expandedand its arrow key inaria-keyshortcuts. Down is a toggle button, “Draw the bow”, pressed while it is drawn. - The row is a listbox; the option under the frame is its active descendant, named with its item, “equipped”, the count and the durability. The drawn name, counts and boxes are hidden, so nothing is read twice.
- A polite live region says what was equipped and when the bow is drawn or put away.
Pointer and touch
Holding a slot and sliding over the tiles is a drag, so every choice also works with single taps: tap a slot, then tap a tile. A tap elsewhere on the stage closes the row (WCAG 2.5.7, AA). Nothing has to be held for long: the hold counts from 260 ms.
Motion
Under reduced motion the row appears and goes at once, the frame and strip jump instead of gliding, nothing pops, bumps or nudges, and the demo never plays. Elsewhere the reader’s first press, key or focus stops the demo for good: a row the demo had open closes, it never acts on a row the reader opened, and it doesn’t start again on its own (WCAG 2.2.2, Pause, stop, hide).
Contrast
The HUD brings its own dark plates, so its words and marks read the same on a light or a dark page: the item’s name is white on its dark pill, the counts cream on dark tiles, and on the blue equipped tile the count wears a dark halo that it reads against (WCAG 1.4.3, Contrast (minimum)). The key legend’s chips hold more than 4.5:1 in both schemes.
In this build
- The slots are buttons named by their slot and item (“Weapons: Iron sword”, “Arrows: Arrow, 58 left”), with aria-haspopup="listbox", aria-expanded and aria-keyshortcuts; Enter or Space opens a slot’s row and leaves it open.
- The open row is a listbox that takes focus, with each tile an option (its name, whether it is equipped, its count or durability) and aria-activedescendant on the frame’s tile; arrows or A/D move, Home and End jump, Enter equips, Escape cancels, and focus returns to the slot.
- Equips and stance changes are announced in a polite live region; the demo’s are not. The frame, the label above it, the stick glyph and the d-pad dots are aria-hidden: the listbox says the same.
- Every slot and tile works with a pointer alone (press and hold, or tap), and the d-pad keeps a minimum size on a phone. Under reduced motion nothing glides, bumps or pops, and the demo does not play.
The complete source behind this demo. Open source under the MIT license, © 2026 Bruno Delorence: copy it, change it, ship it.
// Copyright (c) 2026 Bruno Delorence. MIT License.'use client';import { useEffect, useEffectEvent, useId, useMemo, useReducer, useRef, useState, type CSSProperties, type KeyboardEvent, type PointerEvent as ReactPointerEvent,} from 'react';import { ItemIcon, PadDot, StickGlyph, type IconKind } from './icons';import { useAutoplay } from './use-autoplay';import styles from './quick-selector.module.css';/* * Quick selector: how a game lets the player swap gear in the middle of play, without a menu. * * - The HUD cluster (always on, on its own dark disc) says what is in each slot at a glance: the// Copyright (c) 2026 Bruno Delorence. MIT License.export type IconKind = | 'magnet' | 'orb-bomb' | 'box-bomb' | 'time-lock' | 'frost' | 'sword' | 'axe' | 'club' | 'spear' | 'heater' | 'round' | 'tower' | 'bow' | 'longbow' | 'arrow' | 'fire-arrow' | 'ice-arrow' | 'shock-arrow' | 'bomb-arrow';const ITEM_IMAGES: Record<IconKind, string> = {/* Quick selector (quick-selector.tsx): the HUD's d-pad cluster and, while a slot is held, that slot's row of items above it, alone on the page's stage. Sizes are in --u, one unit of the kit's art (a tile is 112 units, the HUD's magnet 36), which the stage sets from its width (a container query): 1 px at full size, down to 0.4 px on a narrow phone. The HUD is drawn 1.3 times larger, with a floor, so its d-pad stays readable and pressable. With no game scene behind it, the element brings its own contrast, as a HUD over a bright sky does: the cluster sits on a dark disc, the item's name on a dark pill, the tiles carry a hairline edge on a dark stage, and the cream glyphs are outlined in dark. Those plates are the same on both schemes; only the stage around them and the key chips follow the scheme. Everything is CSS and SVG, drawn at the screen's resolution: no blur on any shape. The glows are box shadows and drop shadows, layers behind sharp shapes. Motion: the row rises in and its tiles stagger in (keyframes on mount); the strip and the frame glide by transitions of translate; the bump, the flood, the pop, the flip and the shot are keyframes on the parts they move. Under reduced motion, all of it is instant. */@property --qs-fade-l { syntax: '<number>'; inherits: true; initial-value: 0;// Copyright (c) 2026 Bruno Delorence. MIT License.'use client';import { useCallback, useEffect, useRef, useState } from 'react';/* * When a demo may play on its own: while part of it is on screen and the tab is visible, never * under reduced motion, and never again once the reader has used it. `take()` hands it to the * reader for good (until the component remounts), so it never starts again on its own (WCAG * 2.2.2). `hold()` only pauses it, for input that isn't a use (a hover, a wheel over it), and lets * it go on `idle` ms after the last one. */export function useAutoplay<T extends HTMLElement>(idle = 6000) { const ref = useRef<T>(null); const [visible, setVisible] = useState(false); const [reduced, setReduced] = useState(true); const [taken, setTaken] = useState(false); const [held, setHeld] = useState(false); const timer = useRef(0); useEffect(() => { const element = ref.current; if (!element) return;