Getting Started

The iOS scroll-wheel picker for the web.

Flick a wheel and it coasts, then snaps to an item. It's for times, dates or any list, and works with drag, trackpad, mouse wheel and keyboard.

Installation#

Install the package from your command line.

pnpm add tambour

Create a picker#

Compose the parts. Each wheel holds one position in the Root's value.

time-picker.tsx
import { Tambour } from "tambour/react";
import { useState } from "react";

const hours = Array.from({ length: 12 }, (_, i) => String(i + 1));
const minutes = Array.from({ length: 60 }, (_, i) =>
	String(i).padStart(2, "0"),
);

export function TimePicker() {
	const [time, setTime] = useState(["9", "41", "AM"]);

	return (
		<Tambour.Root value={time} onValueChange={setTime} aria-label="Time">
			<Tambour.Wheel items={hours} loop aria-label="Hour" />
			<Tambour.Wheel items={minutes} loop aria-label="Minute" />
			<Tambour.Wheel items={["AM", "PM"]} aria-label="AM or PM" />
		</Tambour.Root>
	);
}

Style it#

There's no stylesheet to import. tambour renders the cylinder and center band as is, and inherits color and font from the page. Set a variable to change the look.

<Tambour.Root className="[--tambour-band-radius:12px]">
	{/* ... */}
</Tambour.Root>

The row at the center has data-selected to style against. See Styling for the rest.