Bruno DelorenceBruno
Appearance
Appearance

Choose your reading theme.

Contact

Ability icons

A game HUD’s ability kit: bold coloured glyphs, an equipped slot with a 48-tick cooldown ring, and a ready flash.

ability-icons/ability-icons.tsx
Live · interactive

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

  • A game HUD with a small kit of abilities, one equipped at a time, that the player swaps between and fires.
  • Abilities with cooldowns, where the player has to read without looking whether the equipped one can be used again.
  • A kit whose pieces are told apart by colour first and by shape second: each glyph keeps one colour on any backdrop.
  • Showing that some abilities have been upgraded, with a badge that pops in when the upgrade lands.
  • Choosing the ability with a d-pad, the arrow keys or a tap, and firing it from a button, Enter or L.

When not to use

  • An inventory of many items with counts. Use a grid of slots, or a quick selector wheel for a handful.
  • A single timed effect with no choice to make. Use an effect timer.
  • A resource that drains and refills while it is used, like stamina or heat. Use a stamina wheel or a heat gauge.
  • A toolbar in an app. Use a segmented control or icon buttons with tooltips; the dark HUD plates belong in a game.
  • Showing which button fires what. Use button hints or controller glyphs.

Cooldowns

  • Each ability has its own: 4 s for the bombs, 8 s for the time lock, 3 s for the ice block, 6 s for the motorbike; the magnet and the camera have none. cooldowns overrides any of them in seconds, and 0 turns one off.
  • The ring runs on the clock, not on frames, so it shows the real time left even when the frame rate drops. Match it to the game’s own timer.
  • Too early is refused: the slot shakes, the live region says how long is left and onUse isn’t called. Fire the action from onUse, never from the click.

Kit size

The strip is laid out for seven 80 px cells and scales down with the stage until it fits a 320 px phone. A shorter kit keeps the same scale and just makes the strip narrower. There is no row wrap and no scrolling, so seven is the most it holds.

Each one drawn with the component itself, used well or badly.

The HUD’s words are few: the ability names in ABILITIES, the Use button and what the live region says. Keep any you add in the same voice.

  • A name of one or two words, in sentence case: Round bomb, Time lock. It sits on a pill under the strip and is read out with each radio.
  • “+” for an upgrade, after the name with a space: Time lock +. The component adds it; don’t put it in the name.
  • One verb on the button: Use. Screen readers hear the ability after it, so the visible word can stay short.
  • Announcements say what happened and what’s next: Time lock used. Ready in 8 s., Round bomb is not ready: 3 s left., Round bomb ready.

You can add this component with the shadcn CLI or by hand:

Into components/ability-icons of any React project, with no setup:

Terminal
npx shadcn@latest add https://brunodelorence.com/r/ability-icons.json

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

hud.tsx
import { AbilityIcons } from './ability-icons';export function Hud() {  return (    <AbilityIcons      defaultSelected="lock"      upgraded={['round-bomb', 'lock']}      cooldowns={{ lock: 12 }}      onUse={(ability) => console.log('used', ability)}      autoplay={false}    />  );}

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.

The tool abilities of an adventure game, each a flat glyph in its own colour so the player knows it before its shape. Equip one from the strip and use it: the slot’s ring goes dark and lights again tick by tick, clockwise; trying too early shakes the slot, and the last tick flashes it ready. Upgraded abilities wear a cream “+”.

  • Seven original generated Eventide ability emblems use distinct silhouettes and the established ability colors. Cooldowns, upgrade badges and input states remain vector and interactive.
  • The equipped slot sits in a ring of 48 ticks, 3 units wide from radius 33 to 50 of a 100-unit box. Using an ability with a cooldown darkens every tick at once; they light again one by one from 12 o’clock, clockwise.
  • Cooldowns are kept as a start time and a length, so they run on the clock, not on frames. A requestAnimationFrame loop only turns the elapsed time into a tick count, runs while something cools and the HUD is on screen, and sets state only when a count changes: 48 times per cooldown.
  • The strip shows the same progress for every cooling ability in a small ring of its own: the same 48 ticks in a thinner SVG band, lit by the same count.
  • The moments a player feels are Web Animations on transforms, opacity and filters: the use kick (a squash, then a punch), the shake of an ability used too early, the white flash and swell of the ring when it is ready again, the pop of a “+”. Under reduced motion they are skipped; the ring still counts.
  • While on screen and untouched, the HUD plays a round of play: bombs thrown, one tried too early, abilities equipped by walking the strip like a d-pad, an upgrade. Any input of the reader’s ends it.
  • The HUD sits on its own, centred on a plain stage (white, or near-black at night: light-dark() tokens following the page’s color-scheme or the colorScheme prop). Like a game’s HUD it brings its own dark plates, behind the strip, the name, the slot and the Use button, so the glyphs, the cream words and the ring’s dark ticks read the same on either; on the light stage the plates cast a soft shadow.
  • The rune images retain the original game art. Tick rings, plates, focus and cooldown effects remain vector and CSS; the imagery is decorative and excluded from the code MIT license.
PropTypeDefaultDescription
abilitiesAbilityId[]all sevenThe abilities the strip lists, in order: 'round-bomb', 'square-bomb', 'magnet', 'lock', 'ice', 'camera', 'bike'.
defaultSelectedAbilityIdthe firstThe ability equipped at first.
selectedAbilityId—The equipped ability, controlled; pair it with onSelectedChange.
onSelectedChange(ability: AbilityId) => void—Called when another ability is equipped.
upgradedAbilityId[]['round-bomb', 'square-bomb', 'lock']The abilities that wear the “+” of an upgrade.
cooldownsPartial<Record<AbilityId, number>>—Cooldowns in seconds, overriding each ability’s own (bombs 4, lock 8, ice 3, bike 6, magnet and camera none); 0 for none.
onUse(ability: AbilityId) => void—Called when the equipped ability is used; not when it is refused because it is still cooling.
defaultCoolingPartial<Record<AbilityId, number>>—Abilities already cooling at first, each with the share of its cooldown that has passed (0 to 1); the ring counts on from there. Turns the demo off.
autoplaybooleantrueWhile on screen and untouched, the HUD plays a short round of play. Any input hands it to the reader.
colorScheme'light' | 'dark' | 'system'—A light or dark stage, or the reader’s; without it, the page’s color-scheme.
classNamestring—Added to the stage.

Colour and contrast

  • Every glyph reaches at least 3:1 against its plate, for graphics (WCAG 1.4.11): the magnet is the lowest, about 3.5:1 on the light stage’s plate and 4.2:1 on the dark one’s.
  • Colour is never the only cue (1.4.1): the blues share a hue but not a shape, and each radio is named with its ability.
  • The ring’s lit and dark ticks differ by about 13:1, so the share that has passed reads at a glance. A cooling glyph fades to half, which is a state, not content to read.

Target size

A strip cell is 80 × 80 px on a wide stage and shrinks with it, to about 41 px on a 320 px phone; the Use button is at least 32 px tall. Both stay above the 24 × 24 px minimum (2.5.8, AA); only the full-size cells reach 44 px (2.5.5, AAA).

Keyboard

  • The strip is one Tab stop. The arrow keys move round it (wrapping at the ends), Home and End jump, and Enter uses the equipped ability.
  • Use is the next Tab stop. While its ability cools it is aria-disabled, not disabled, so it stays focusable and answers with the time left.
  • L, the key on the button, uses the equipped ability while focus is anywhere in the HUD (aria-keyshortcuts="L"). It only listens there, so it never takes the key from the page or from a text field (WCAG 2.1.4, Character key shortcuts).
  • Focus is a 2 px blue ring, 2 px out, only from the keyboard (:focus-visible). It keeps at least 3:1 against the plates and the stage in both schemes (WCAG 1.4.11).

Motion

The demo round stops for good at the reader’s first input and doesn’t start again on its own (2.2.2). Under reduced motion it never plays, the kick, the shake, the ready flash and the “+” pop are skipped, and the name and glyph swap without moving (2.3.3); the rings still count. The ready flash is a single pulse, well under three a second (2.3.1).

In this build

  • The strip is a radiogroup: one Tab stop, the arrow keys, Home and End equip an ability, and Enter uses the equipped one. Each radio is named with its ability, its upgrade and whether it is cooling.
  • Use is a real button named with the ability it fires; while that ability cools it is marked aria-disabled but still answers, with the shake and the time left.
  • A polite live region says what happens: equipped, used and ready in how long, not ready yet, ready, upgraded.
  • The glyphs, the slot and its ring are decorative (aria-hidden): every fact they show is in the names and the live region. The exported AbilityGlyph takes a title when a glyph should be announced on its own.
  • Reduced motion turns off the demo and every kick, shake, flash and pop; the rings keep counting. Focus is a cream ring on the strip and the button.

The complete source behind this demo. Open source under the MIT license, © 2026 Bruno Delorence: copy it, change it, ship it.

ability-icons.tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.'use client';import {  useEffect,  useEffectEvent,  useRef,  useState,  type KeyboardEvent as ReactKeyboardEvent,} from 'react';import { ABILITIES, ABILITY_IDS, AbilityGlyph, type AbilityId } from './glyphs';import { useAutoplay } from './use-autoplay';import styles from './ability-icons.module.css';export { AbilityGlyph, ABILITIES, ABILITY_IDS, type AbilityId } from './glyphs';/* * Ability icons: the tool abilities of a game HUD, shown on their own on a plain stage. A strip * lists the kit, one glyph per ability in its own colour; the equipped one also sits in a slot * inside a ring of 48 ticks, which is how the player reads, without looking, whether it can be * used again. Like a game's HUD it brings its own dark plates, so it reads on any backdrop. * * - Using an ability kicks its glyph (a squash, then a punch) and, if it has a cooldown, darkens
glyphs.tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.'use client';// Original Eventide ability paintings; state and upgrade badges are drawn by the component.export type AbilityId =  'round-bomb' | 'square-bomb' | 'magnet' | 'lock' | 'ice' | 'camera' | 'bike';export const ABILITY_IDS: AbilityId[] = [  'round-bomb',  'square-bomb',  'magnet',  'lock',  'ice',  'camera',  'bike',];export type Ability = {  name: string;  /** Its colour, which the player learns before its shape. */  color: string;  /** Seconds before it can be used again; 0 for none. */
use-autoplay.ts
// 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 a demo never starts up again on its own * (WCAG 2.2.2). */export function useAutoplay<T extends HTMLElement>() {  const ref = useRef<T>(null);  const [visible, setVisible] = useState(false);  const [reduced, setReduced] = useState(true);  const [taken, setTaken] = useState(false);  useEffect(() => {    const element = ref.current;    if (!element) return;    let onScreen = false;    const update = () => setVisible(onScreen && !document.hidden);    const observer = new IntersectionObserver(
ability-icons.module.css
/* Ability icons (ability-icons.tsx): the HUD on its own, centred on the lab's plain stage, white by   day and near-black at night: the ability strip on top, the equipped ability's name under it, then   the equipped slot with its cooldown ring and the Use button.   Sizes are in units of the drawing, `--u` for the strip and `--s` for the slot: one unit is 1px   when the stage is wide enough, and both shrink with the stage's width (a container query), so   the strip always fits a 320px phone.   Colours are the tokens below, light-dark(light, dark) where the two differ: the component takes   the color-scheme it inherits from the page, or the one its colorScheme prop sets   (data-color-scheme). As in a game, the HUD brings its own dark plates (the strip, the name's   pill, the slot's disc, the Use pill), so the glyphs, the cream words and the ring's dark ticks   read the same on a white stage and a black one; on the light stage the plates also cast a soft   shadow so they sit on it.   Crispness. Everything is vector: SVG glyphs and rings, CSS plates. No shape is blurred or scaled   as a bitmap; the only soft things are glows and shadows, painted behind the sharp shapes.   Memory. The stage is one layout boundary sized from outside. The rings' ticks change only an   attribute, 48 times per cooldown; everything that moves does it by transform, opacity or   filter. */.root {  /* The stage, and its edge. */