날짜·시간 선택기
날짜·시간 선택기 (Datetime Picker)
날짜·시간 선택기는 캘린더와 시계 인터페이스를 활용해 날짜와 시간 값을 선택하게 해주는 컴포넌트예요. 날짜만 고르는 DatePicker, 날짜와 시간을 함께 고르는 DateTimePicker, 시간만 고르는 TimePicker가 있어요.
출처: 문서
본문
DatePicker 컴포넌트
캘린더 지원과 함께 날짜 값을 선택하게 해주는 컴포넌트예요.
- Keywords: date, picker, input, calendar, selection, form
- Categories: form
- Status: general-availability
예시
import DatePicker from '@atlaskit/datetime-picker/date-picker';
import __noop from '@atlaskit/ds-lib/noop';
const Example = (): React.JSX.Element => (
<DatePicker
clearControlLabel="Clear select date"
onChange={__noop}
shouldShowCalendarButton
openCalendarLabel="open calendar"
/>
);
export default Example;
Props
| Prop | Type | Description |
|---|---|---|
aria-describedby |
string |
Used to associate accessible descriptions to the date picker |
autoFocus |
boolean |
Set the picker to autofocus on mount |
clearControlLabel |
string |
Set the aria-label for the clear button |
dateFormat |
string |
Format the date with a string that is accepted by date-fns's format function |
defaultValue |
string |
The default for value |
disabled |
string[] |
An array of ISO dates that should be disabled on the calendar |
disabledDateFilter |
(date: string) => boolean |
A filter function for disabling dates on the calendar |
formatDisplayLabel |
(value: string, dateFormat: string) => string |
A function for formatting the date displayed in the input |
id |
string |
Set the id of the field |
inputLabel |
string |
The name of the input, used when shouldShowCalendarButton is true |
inputLabelId |
string |
The ID of the label for the input, used when shouldShowCalendarButton is true |
isDisabled |
boolean |
Set if the picker is disabled |
isInvalid |
boolean |
Set if the picker has an invalid value |
isOpen |
boolean |
Set if the picker is open |
isRequired |
boolean |
Set the field as required |
label |
string |
Accessible name for the Date Picker Select, rendered as aria-label |
locale |
string |
Locale used to format the date and calendar |
maxDate |
string |
The latest enabled date |
minDate |
string |
The earliest enabled date |
name |
string |
The name of the field |
nextMonthLabel |
string |
The aria-label attribute associated with the next-month arrow |
onBlur |
(event: FocusEvent<HTMLInputElement, Element>) => void |
Called when the field is blurred |
onChange |
(value: string) => void |
Called when the value changes |
onFocus |
(event: FocusEvent<HTMLInputElement, Element>) => void |
Called when the field is focused |
openCalendarLabel |
string |
The label associated with the button to open the calendar, rendered via the shouldShowCalendarButton prop |
parseInputValue |
(date: string, dateFormat: string) => Date |
A function for parsing input characters and transforming them into a Date object |
placeholder |
string |
Placeholder text displayed in input |
previousMonthLabel |
string |
The aria-label attribute associated with the previous-month arrow |
selectProps |
Omit<SelectProps<OptionType, false>, "aria-describedby" | "aria-label" | "placeholder" | "inputId"> & { 'aria-describedby'?: never; 'aria-label'?: never; inputId?: never; placeholder?: never; } & { ...; } |
|
shouldShowCalendarButton |
boolean |
Provides a functional calendar button that opens the calendar picker that lives on the right side of the date picker |
spacing |
"default" | "compact" |
The spacing for the select control |
value |
string |
The ISO time used as the input value |
weekStartDay |
0 | 1 | 2 | 3 | 4 | 5 | 6 |
Start day of the week for the calendar |
사용 지침
- 날짜 선택에만 사용해요
- 명확한 날짜 형식을 제공해요
- 날짜 검증을 적절히 처리해요
- 캘린더 버튼의 표시 여부를 고려해요
콘텐츠 지침
- 명확하고 설명적인 라벨을 사용해요
- 도움이 되는 플레이스홀더 텍스트를 제공해요
- 라벨을 간결하되 설명적으로 유지해요
- 날짜 형식 현지화에는 locale prop을 사용해요
접근성 지침
- 올바른 키보드 탐색을 보장해요
- 적절한 날짜 형식을 사용해요
- 명확한 날짜 라벨을 제공해요
- 스크린 리더 안내를 고려해요
DateTimePicker 컴포넌트
날짜와 시간 값을 모두 선택하게 해주는 컴포넌트예요.
- Keywords: datetime, picker, date, time, input, calendar
- Categories: form
- Status: general-availability
예시
import DateTimePicker from '@atlaskit/datetime-picker/date-time-picker';
import __noop from '@atlaskit/ds-lib/noop';
const Example = (): React.JSX.Element => (
<DateTimePicker
clearControlLabel="Clear date / time picker (editable times)"
defaultValue="2018-01-02T14:30+10:00"
onChange={__noop}
timePickerProps={{
timeIsEditable: true,
label: 'Time picker (editable)',
}}
datePickerProps={{
label: 'Date picker (editable times)',
shouldShowCalendarButton: true,
openCalendarLabel: 'open calendar',
}}
/>
);
export default Example;
Props
| Prop | Type | Description |
|---|---|---|
aria-describedby |
string |
Used to associate accessible descriptions to both the date and time picker |
autoFocus |
boolean |
Set the picker to autofocus on mount |
clearControlLabel |
string |
Set the aria-label for the clear button |
datePickerProps |
DatePickerBaseProps |
Props applied to the DatePicker |
defaultValue |
string |
The default for value |
id |
string |
Set the id of the field |
isDisabled |
boolean |
Set if the field is disabled |
isInvalid |
boolean |
Set if the picker has an invalid value |
isRequired |
boolean |
Set the field as required |
locale |
string |
Locale used for formatting dates and times |
name |
string |
The name of the field |
onBlur |
(event: FocusEvent<HTMLInputElement, Element>) => void |
Called when the field is blurred |
onChange |
(value: string) => void |
Called when the value changes and the date / time is a complete value, or empty |
onFocus |
(event: FocusEvent<HTMLInputElement, Element>) => void |
Called when the field is focused |
parseValue |
(dateTimeValue: string, date: string, time: string, timezone: string) => { dateValue: string; timeValue: string; zoneValue: string; } |
Function used to parse datetime values into their date, time and timezone sub-values |
spacing |
"default" | "compact" |
The spacing for the select control |
timePickerProps |
TimePickerBaseProps |
Props applied to the TimePicker |
value |
string |
The ISO time that should be used as the input value |
사용 지침
- 날짜와 시간을 함께 선택할 때 사용해요
- 명확한 날짜/시간 형식을 제공해요
- 시간대(timezone)를 고려해요
- 검증 요구 사항을 고려해요
콘텐츠 지침
- 명확하고 설명적인 라벨을 사용해요
- 도움이 되는 플레이스홀더 텍스트를 제공해요
- 적절한 날짜/시간 형식을 사용해요
- 라벨을 간결하되 설명적으로 유지해요
- 날짜와 시간 형식 현지화에는 locale prop을 사용해요
접근성 지침
- 올바른 키보드 탐색을 보장해요
- 적절한 날짜/시간 형식을 사용해요
- 명확한 날짜/시간 라벨을 제공해요
- 스크린 리더 안내를 고려해요
TimePicker 컴포넌트
시계 인터페이스와 함께 시간 값을 선택하게 해주는 컴포넌트예요.
- Keywords: time, picker, input, clock, selection, form
- Categories: form
- Status: general-availability
예시
import TimePicker from '@atlaskit/datetime-picker/time-picker';
import __noop from '@atlaskit/ds-lib/noop';
const Example = (): React.JSX.Element => (
<TimePicker
clearControlLabel="Clear select time (editable)"
defaultValue="14:30"
onChange={__noop}
timeFormat="HH:mm:ss A"
timeIsEditable
selectProps={{
classNamePrefix: 'timepicker-select',
}}
/>
);
export default Example;
Props
| Prop | Type | Description |
|---|---|---|
aria-describedby |
string |
Used to associate accessible descriptions to the time picker |
autoFocus |
boolean |
Set the picker to autofocus on mount |
clearControlLabel |
string |
Set the aria-label for the clear button |
defaultValue |
string |
The default for value |
formatDisplayLabel |
(time: string, timeFormat: string) => string |
A function for formatting the displayed time value in the input |
hideIcon |
boolean |
Hides icon for dropdown indicator |
id |
string |
Set the id of the field |
isDisabled |
boolean |
Set if the field is disabled |
isInvalid |
boolean |
Set if the picker has an invalid value |
isOpen |
boolean |
Set if the dropdown is open |
isRequired |
boolean |
Set the field as required |
label |
string |
Accessible name for the Time Picker Select, rendered as aria-label |
locale |
string |
Locale used to format the time |
name |
string |
The name of the field |
onBlur |
(event: FocusEvent<HTMLElement, Element>) => void |
Called when the field is blurred |
onChange |
(value: string) => void |
Called when the value changes |
onFocus |
(event: FocusEvent<HTMLElement, Element>) => void |
Called when the field is focused |
parseInputValue |
(time: string, timeFormat: string) => string | Date |
A function for parsing input characters and transforming them into either a string or a Date object |
placeholder |
string |
Placeholder text displayed in input |
selectProps |
Omit<SelectProps<OptionType, false>, "aria-describedby" | "aria-label" | "placeholder" | "inputId"> & { 'aria-describedby'?: never; 'aria-label'?: never; inputId?: never; placeholder?: never; } |
|
spacing |
"default" | "compact" |
The spacing for the select control |
timeFormat |
string |
Format the time with a string that is accepted by date-fns's format function |
timeIsEditable |
boolean |
Set if users can edit the input, allowing them to add custom times |
times |
string[] |
The times shown in the dropdown |
value |
string |
The ISO time that should be used as the input value |
사용 지침
- 시간 선택에만 사용해요
- 명확한 시간 형식을 제공해요
- 시간 검증을 적절히 처리해요
- 편집 가능한 시간 입력을 고려해요
콘텐츠 지침
- 명확하고 설명적인 라벨을 사용해요
- 도움이 되는 플레이스홀더 텍스트를 제공해요
- 적절한 시간 형식을 사용해요
- 라벨을 간결하되 설명적으로 유지해요
- 시간 형식 현지화에는 locale prop을 사용해요(예: 12시간제 vs 24시간제)
접근성 지침
- 올바른 키보드 탐색을 보장해요
- 적절한 시간 형식을 사용해요
- 명확한 시간 라벨을 제공해요
- 스크린 리더 안내를 고려해요