# Time Picker
URL: /react/components/time-picker
Source: https://github.com/daangn/seed-design/blob/dev/docs/content/react/components/time-picker.mdx
A 12-hour time picker component that allows selecting AM/PM, hours, and minutes by scrolling wheels.
사용 가능 버전: @seed-design/react@2.2.0, @seed-design/css@2.4.0
## Preview
```tsx
import { Box, TimePicker } from "@seed-design/react";
export default function TimePickerPreview() {
return (
);
}
```
## Installation
- npm: npm install @seed-design/react @seed-design/css
- pnpm: pnpm add @seed-design/react @seed-design/css
- yarn: yarn add @seed-design/react @seed-design/css
- bun: bun add @seed-design/react @seed-design/css
## Props
## Examples
### Basic
`TimePicker` provides only the wheel-style time picker UI. Configure the trigger, bottom sheet, confirm and cancel buttons, and form serialization in the consuming screen.
```tsx
import { TimePicker } from "@seed-design/react";
```
### Controlled
You can control the selected time using `value` and `onValueChange`. `onValueChange` is called when scrolling settles on a selection item and the value is confirmed.
Currently, only 12-hour UI is supported. However, `TimePickerValue` used in `value`, `defaultValue`, and `onValueChange` is expressed in 24-hour format without separating AM/PM as a separate field.
If no value is specified, it starts at `00:00`. To start from the current time when no time is selected, pass the current time's `hour` and `minute` as `defaultValue`.
`hour` and `minute` must each be integers within a valid range. Passing invalid `value`, `defaultValue`, or `minuteStep` will result in a `RangeError`.
```tsx
"use client";
import { Box, Text, TimePicker, VStack, type TimePickerValue } from "@seed-design/react";
import * as React from "react";
export default function TimePickerControlled() {
const [value, setValue] = React.useState({ hour: 10, minute: 30 });
return (
{String(value.hour).padStart(2, "0")}:{String(value.minute).padStart(2, "0")}
);
}
```
### Use Case
Determine the layout based on the proportion of space Time Picker occupies on screen and the platform.
- If time selection is the main task on the screen, use **Inline**.
- For time input fields in mobile forms, consider **Bottom Sheet** first.
Bottom Sheet requires a trigger to open the surface. It can be composed with an input-style button like `FieldButton` that displays the current value. Inline confirmation is handled by the screen's action area, and Bottom Sheet confirmation is handled by the confirm button within the surface.
#### Inline
If time selection is one step in a writing or settings flow, place Time Picker directly within the screen flow.
```tsx
"use client";
import { Box, HStack, Text, TimePicker, VStack, type TimePickerValue } from "@seed-design/react";
import { ActionButton } from "seed-design/ui/action-button";
import * as React from "react";
function formatTime({ hour, minute }: TimePickerValue) {
const period = hour < 12 ? "오전" : "오후";
const displayHour = hour % 12 || 12;
return `${period} ${displayHour}:${String(minute).padStart(2, "0")}`;
}
export default function TimePickerInline() {
const [value, setValue] = React.useState({ hour: 10, minute: 30 });
const [savedValue, setSavedValue] = React.useState(value);
return (
영업 시작 시간
현재 설정: {formatTime(savedValue)}
setSavedValue(value)}>
완료
);
}
```
#### Bottom Sheet
In mobile forms, configure Time Picker to appear at the bottom of the screen when the input field is tapped. Manage temporary values until the user completes, and reflect them as the input field's value when the confirm button is tapped.
```tsx
"use client";
import { Portal, TimePicker, type TimePickerValue } from "@seed-design/react";
import { ActionButton } from "seed-design/ui/action-button";
import {
BottomSheetBody,
BottomSheetContent,
BottomSheetFooter,
BottomSheetRoot,
} from "seed-design/ui/bottom-sheet";
import { FieldButton, FieldButtonValue } from "seed-design/ui/field-button";
import * as React from "react";
function formatTime({ hour, minute }: TimePickerValue) {
const period = hour < 12 ? "오전" : "오후";
const displayHour = hour % 12 || 12;
return `${period} ${displayHour}:${String(minute).padStart(2, "0")}`;
}
export default function TimePickerBottomSheet() {
const [open, setOpen] = React.useState(false);
const [value, setValue] = React.useState({ hour: 10, minute: 30 });
const [draft, setDraft] = React.useState(value);
const handleOpenChange = (nextOpen: boolean) => {
if (nextOpen) setDraft(value);
setOpen(nextOpen);
};
return (
handleOpenChange(true),
}}
>
{formatTime(value)}
{
setValue(draft);
setOpen(false);
}}
>
완료
);
}
```
### Using with Date Objects
`TimePicker` does not interpret dates or time zones. If your application manages `Date` as state, convert `hour` and `minute` to `TimePickerValue`, and reflect the changed time in the existing date.
```tsx
"use client";
import { Box, Text, TimePicker, VStack, type TimePickerValue } from "@seed-design/react";
import * as React from "react";
export default function TimePickerDateValue() {
const [date, setDate] = React.useState(() => new Date(2026, 6, 28, 13, 30));
const value: TimePickerValue = {
hour: date.getHours(),
minute: date.getMinutes(),
};
const handleValueChange = ({ hour, minute }: TimePickerValue) => {
setDate((currentDate) => {
const nextDate = new Date(currentDate);
nextDate.setHours(hour, minute, 0, 0);
return nextDate;
});
};
return (
{date.toLocaleString("ko-KR")}
);
}
```
### Minute Step
`minuteStep` can be one of `1`, `5`, `10`, `15`, or `30`, with a default value of `5`.
If the selected minute doesn't match the interval, it rounds to the nearest value. For example, 9:13 displays as 9:15 with `minuteStep={5}`.
Rounding is calculated based on the entire time, so the hour can change together. For example, 23:59 becomes 0:00 with `minuteStep={5}`. When controlling `value`, normalization itself does not trigger `onValueChange`.
The minute column cycles, but the hour is maintained even when crossing boundaries. For example, selecting 00 (the next minute item) from 10:55 results in 10:00.
```tsx
import { Box, TimePicker } from "@seed-design/react";
export default function TimePickerMinuteStep() {
return (
);
}
```
### Disabled
When `disabled` is used, all columns cannot be manipulated or focused.
```tsx
import { Box, TimePicker } from "@seed-design/react";
export default function TimePickerDisabled() {
return (
);
}
```
### Locale
The AM/PM, number notation, and column order vary depending on `locale`.
The default accessibility names for the entire picker and each column are provided in Korean, English, or Japanese depending on `locale`. If a language other than the default is needed or to describe the context more specifically, directly specify `aria-label`, `periodAriaLabel`, `hourAriaLabel`, or `minuteAriaLabel`.
```tsx
import { Box, TimePicker } from "@seed-design/react";
export default function TimePickerLocalization() {
return (
);
}
```
### Accessibility
Time Picker as a whole is provided as `group`, and AM/PM, hour, and minute columns are each provided as `spinbutton`. On keyboard, use `ArrowUp` and `ArrowDown` to select previous/next items, and `Home` and `End` to select first/last items.
If there's an element on screen that indicates the Time Picker's name, you can connect it with `aria-labelledby`. If `aria-labelledby` is not provided, the default `"Time Selection"` is used for the entire component.