# Wheel Picker
URL: /react/components/wheel-picker
Source: https://github.com/daangn/seed-design/blob/dev/docs/content/react/components/wheel-picker.mdx
A component for selecting one or more values by scrolling items vertically.
사용 가능 버전: @seed-design/react@2.4.0, @seed-design/css@2.6.0
## Preview
```tsx
"use client";
import { Box, Text, VStack } from "@seed-design/react";
import * as React from "react";
import { WheelPicker } from "seed-design/ui/wheel-picker";
const buildingOptions = Array.from({ length: 10 }, (_, index) => {
const value = String(101 + index);
return { value, label: `Bldg ${value}` };
});
const unitOptions = Array.from({ length: 15 }, (_, floorIndex) =>
Array.from({ length: 4 }, (_, lineIndex) => {
const value = String((floorIndex + 1) * 100 + lineIndex + 1);
return { value, label: `Unit ${value}` };
}),
).flat();
export default function WheelPickerPreview() {
const [{ building, unit }, setAddress] = React.useState({
building: "103",
unit: "1202",
});
const columns = [
{
id: "building",
"aria-label": "Building",
options: buildingOptions,
value: building,
onValueChange: (nextBuilding: string) =>
setAddress((current) => ({ ...current, building: nextBuilding })),
},
{
id: "unit",
"aria-label": "Unit",
options: unitOptions,
value: unit,
onValueChange: (nextUnit: string) =>
setAddress((current) => ({ ...current, unit: nextUnit })),
},
];
return (
Bldg {building}, Unit {unit}
);
}
```
## Installation
- npm: npx @seed-design/cli@latest add ui:wheel-picker
- pnpm: pnpm dlx @seed-design/cli@latest add ui:wheel-picker
- yarn: yarn dlx @seed-design/cli@latest add ui:wheel-picker
- bun: bun x @seed-design/cli@latest add ui:wheel-picker
## Props
### `WheelPicker`
### `WheelPickerColumn`
## Examples
### Package API
```tsx
"use client";
import { Box, Text, VStack, WheelPicker } from "@seed-design/react";
import * as React from "react";
const options = ["작게", "보통", "크게"].map((label) => ({ value: label, label }));
export default function WheelPickerPackageApi() {
const [value, setValue] = React.useState("보통");
return (
(
{option.label}
)}
/>
선택값: {value}
);
}
```
The compound API of `@seed-design/react` is used when combining columns directly. You can adjust the entire or column-level styles with `className` on `Root` and each `Column`. `renderLabel` replaces the default ItemLabel with a returned element. If you need default spacing and alignment, you can recombine `WheelPicker.ItemLabel` as shown in the example. Slot style API for internal items and selection indicators is not provided.
### Value Change
`onIndexChange` is called whenever the center item changes due to user scrolling or tapping. Since it passes the index and value of each item traversed in order even before settling, it can be used for per-item haptics. Handle the final selected value with `onValueChange` after scrolling settles.
### React Element Label
```tsx
"use client";
import { Box, HStack, Text, VStack } from "@seed-design/react";
import * as React from "react";
import { WheelPicker } from "seed-design/ui/wheel-picker";
function ColorDot({ color }: { color: string }) {
return (
);
}
const colorOptions = [
{ value: "carrot", name: "당근색", color: "#ff6f0f" },
{ value: "blue", name: "파란색", color: "#4285f4" },
{ value: "green", name: "초록색", color: "#22a06b" },
].map(({ value, name, color }) => ({
value,
ariaLabel: name,
label: (
{name}
),
}));
export default function WheelPickerReactElementLabel() {
const [value, setValue] = React.useState("carrot");
return (
선택값: {value}
);
}
```
String and number labels are used as-is for accessibility names. If you use React elements as labels, provide `ariaLabel` for each option. When accessibility text needs to be calculated separately, use `getAriaValueText`. Internal elements must inherit `currentColor`, and buttons, links, input elements, and multi-line content should not be included.
### Disabled
```tsx
import { Box, Text, VStack, WheelPicker } from "@seed-design/react";
const options = ["낮음", "보통", "높음"].map((label) => ({ value: label, label }));
export default function WheelPickerStates() {
return (
Disabled
);
}
```
`disabled` prevents both focus and manipulation of the column.
### Data Contract
- Provide one or more items in `options` for each column.
- The option's `value` must be unique within the column.
- The controlled `value` must be in the current `options`.
- When a dependent column changes, pass new `options` and valid `value` in the same render.
- If external `value` changes while the user is manipulating or waiting to settle, scroll position synchronization for that change is skipped.
- Handle loading, error, and empty states outside Wheel Picker.
Wheel Picker does not automatically correct invalid values to the first item or call a correction callback. Configure date calculation, column dependencies, hidden inputs, and confirmation UI on the consuming side.
### Accessibility
The entire Wheel Picker is provided as `group`, and each column as `spinbutton`. Specify `aria-label` or `aria-labelledby` on `Root` and each `Column`.
On keyboard, use `ArrowUp` and `ArrowDown` to select previous/next items. `Home` and `End` move to first/last items. Use `Tab` to move between columns.