Perk Picker
A "Level up! Pick one" screen: a few perk cards pop in, the player chooses one and confirms. Rarity colours the card edge, upgrades show "Lv 2 → 3" or "New", and the game can offer rerolls and a skip. Cards are a row on wide containers and a vertical list on narrow ones. Controlled or uncontrolled, with radiogroup keyboard support.
Three village perks of different rarities. Reroll (2 left) deals a new set and replays the reveal, Skip hands out coins, Take it confirms with a toast. Double-click or press Enter on a card to confirm it.
Level up!
Pick one perk for your village.
Installation
Usage
Keyboard: the cards are a radio group. Arrow keys, Home and End move and select, Space selects, Enter selects and confirms. The choice is announced through a polite live region.
The picker holds no rules. After a reroll or a confirm, pass a new perks array; an uncontrolled choice that is no longer offered is cleared.
Reduced motion removes the staggered pop-in.
Examples
List in a narrow card
variant="list" forces the vertical layout. Without it the picker switches by the width of its own container, not the screen.
Pick a tool perk
Controlled, new and locked
value and onValueChange keep the choice in your state. locked can be a reason string. A perk with level: 0 shows "New".
Controlled choice
Chosen id: tea
API
Everything else is passed through to the underlying element or Radix primitive.
| Prop | Type | Default | Description |
|---|---|---|---|
perks | Perk<T>[] | – | { id, name, label?, icon?, description?, rarity?, tags?, level?, maxLevel?, stats?, locked?, data? }. `icon` is a React node or an image URL. A new array with different ids replays the reveal. |
value / defaultValue / onValueChange | string | null / (id, perk) => void | null | The chosen perk id. Arrow keys, click and tap change it. |
onConfirm / confirmLabel | (perk) => void / ReactNode | "Take it" | Setting onConfirm shows the confirm button. Double-click and Enter on a card confirm too. |
title / subtitle | ReactNode | "Pick a perk" | Heading and the line under it. |
rerolls / onReroll | number / () => void | – | Shows "Reroll (2)"; disabled at 0. The game decides the new perks and passes a new `perks` array. |
onSkip / skipLabel | () => void / ReactNode | "Skip" | A secondary way out, e.g. "Skip, +50 coins". |
variant | "cards" | "list" | auto | Auto uses cards when the container is at least 560px wide and a list below that. |
renderPerk | (perk, { selected, locked, index }) => ReactNode | – | Replace the inside of a card; frame, selection and keyboard stay. |
rarities | Record<string, { label, color }> | DEFAULT_RARITIES | Your own rarity names and colours. |
labels | Partial<PerkPickerLabels> | English | title, new, upgrade ("Lv {from} → {to}"), max, confirm, reroll, skip, chosen ("{name} chosen"), locked, empty. |