Let one wheel's items follow another's value.
It starts on January 31st. Move the month to February.
How it works#
Derive the items from the value. If the selected item disappears, the wheel moves to the nearest one and reports it through onValueChange.
const [month, , year] = date;
const days = useMemo(() => listDays(month, year), [month, year]);
<Tambour.Root value={date} onValueChange={setDate}>
<Tambour.Wheel items={months} />
<Tambour.Wheel items={days} />
<Tambour.Wheel items={years} />
</Tambour.Root>;Controlled values#
A controlled wheel follows its parent. Changing value animates to the new item, and if the parent ignores or alters a change, the wheel moves to match when it comes to rest.
Change and commit#
onValueChange runs as a wheel crosses each item, which suits a live readout. For anything heavier, like saving, use onValueCommit, which waits until a change made by the user comes to rest.
<Tambour.Root value={date} onValueChange={setDate} onValueCommit={save}>
{/* ... */}
</Tambour.Root>