2.4.1 ⢠Published 11 months ago
@s77rt/react-native-date-picker v2.4.1
Features
- š Date picker
- š Time picker
- šļø Datetime picker
- š Yearmonth picker
- š Supports iOS, Android and Web
- š Renders in modal and inline
- ⨠Highly customizable
Screenshots
| iOS | Android | mWeb - Safari | mWeb - Chrome | Web - Chrome |
|---|---|---|---|---|
https://github.com/user-attachments/assets/f46f5132-3385-48c9-8d1b-ee478b60fba8
Installation
Using
npmnpm install @s77rt/react-native-date-pickerUsing
yarnyarn add @s77rt/react-native-date-picker
Usage
import { DatePicker } from "@s77rt/react-native-date-picker";
import type { DatePickerHandle } from "@s77rt/react-native-date-picker";Modal
function Example() {
const datePicker = useRef<DatePickerHandle>(null);
const [selectedDate, setSelectedDate] = useState<Date | null>(null);
return (
<>
<Text>Selected date: {selectedDate?.toLocaleDateString()}</Text>
<View>
<Button
title="Select date š
"
onPress={() => datePicker.current?.showPicker()}
/>
<DatePicker
ref={datePicker}
type="date"
value={selectedDate}
onChange={setSelectedDate}
/>
</View>
</>
);
}Inline
function Example() {
const [selectedDate, setSelectedDate] = useState<Date | null>(null);
return (
<>
<Text>Selected date: {selectedDate?.toLocaleDateString()}</Text>
<DatePicker
type="date"
value={selectedDate}
onChange={setSelectedDate}
inline
/>
</>
);
}Props
Inherits View Props.
| Prop | Type | Description |
|---|---|---|
ref | Ref<DatePickerHandle> | Ref for the date picker handle. |
type | Type | The type of the picker. |
value | Date \| null | The selected date. |
onChange | (value: Date \| null) => void | Callback when the user changes the selected date. |
min | Date | The earliest selectable date. |
max | Date | The latest selectable date. |
step | number | The stepping interval, in seconds. ā«šµ |
inline | boolean | Whether the date picker should be displayed inline. ā«š¢ |
options | Options | Options. Note: Must be memoized (useMemo). ā«š¢ |
styles | Styles | Styles. Note: Must be memoized (useMemo). ā«š¢ |
Type
The type of the picker and can be one of the following:
datetimedatetimeā«šµyearmonthā«šµ
Options
Various configuration options.
| Option | Type | Description |
|---|---|---|
locale | string | The locale BCP-47 identifier. ā« |
confirmText | string | The confirm button text. ā«š¢ |
cancelText | string | The cancel button text. ā«š¢ |
mode | "compact" \| "graphical" \| "wheel" | The display mode. ā« |
title | string | The title. š¢ |
headline | string | The headline. š¢ |
showModeToggle | boolean | Whether the mode toggle should be shown. š¢ |
is24Hour | boolean | Whether the time should be in 24-hour. š¢ |
Styles
Look and feel styles.
| Style | Type | Description |
|---|---|---|
accentColor | ColorValue | The accent color. ā« |
containerColor | ColorValue | The container color. š¢ |
titleContentColor | ColorValue | The title color. š¢ |
headlineContentColor | ColorValue | The headline color. š¢ |
weekdayContentColor | ColorValue | The weekday letters color. š¢ |
subheadContentColor | ColorValue | The month and year subhead labels color. š¢ |
navigationContentColor | ColorValue | The year and arrow buttons color. š¢ |
yearContentColor | ColorValue | The year color. š¢ |
disabledYearContentColor | ColorValue | The disabled year color. š¢ |
currentYearContentColor | ColorValue | The current year color. š¢ |
selectedYearContentColor | ColorValue | The selected year color. š¢ |
disabledSelectedYearContentColor | ColorValue | The disabled selected year color. š¢ |
selectedYearContainerColor | ColorValue | The selected year container color. š¢ |
disabledSelectedYearContainerColor | ColorValue | The disabled selected container color. š¢ |
dayContentColor | ColorValue | The day color. š¢ |
disabledDayContentColor | ColorValue | The disabled day color. š¢ |
selectedDayContentColor | ColorValue | The selected day color. š¢ |
disabledSelectedDayContentColor | ColorValue | The disabled selected day color. š¢ |
selectedDayContainerColor | ColorValue | The selected day container color. š¢ |
disabledSelectedDayContainerColor | ColorValue | The disabled selected day container color. š¢ |
todayContentColor | ColorValue | The today color. š¢ |
todayDateBorderColor | ColorValue | The today border color. š¢ |
dayInSelectionRangeContainerColor | ColorValue | The selected days container color. š¢ |
dayInSelectionRangeContentColor | ColorValue | The selected days color. š¢ |
dividerColor | ColorValue | The divider color. š¢ |
clockDialColor | ColorValue | The clock dial color. š¢ |
selectorColor | ColorValue | The clock dial selector color. š¢ |
periodSelectorBorderColor | ColorValue | The period selector border color. š¢ |
clockDialSelectedContentColor | ColorValue | The selected number color. š¢ |
clockDialUnselectedContentColor | ColorValue | The unselected number color. š¢ |
periodSelectorSelectedContainerColor | ColorValue | The selected period container color. š¢ |
periodSelectorUnselectedContainerColor | ColorValue | The unselected period container color. š¢ |
periodSelectorSelectedContentColor | ColorValue | The selected period color. š¢ |
periodSelectorUnselectedContentColor | ColorValue | The unselected period color. š¢ |
timeSelectorSelectedContainerColor | ColorValue | The selected time container color. š¢ |
timeSelectorUnselectedContainerColor | ColorValue | The unselected time container color. š¢ |
timeSelectorSelectedContentColor | ColorValue | The selected time color. š¢ |
timeSelectorUnselectedContentColor | ColorValue | The unselected time color. š¢ |
Methods
Imperative handle methods.
| Method | Type | Description |
|---|---|---|
showPicker | () => void | Shows the picker. |
Feedback
Every code review, bug report and feature request is appreciated! Please feel free to share your feedback.
License
ā« iOS - š¢ Android - šµ Web
2.4.1
11 months ago
2.4.0
11 months ago
2.3.2
11 months ago
2.3.1
11 months ago
2.3.0
11 months ago
2.2.2
11 months ago
2.2.1
11 months ago
2.2.0
11 months ago
2.1.0
11 months ago
2.0.1
11 months ago
2.0.0
11 months ago
1.4.0
11 months ago
1.3.0
12 months ago
1.2.0
12 months ago
1.1.0
12 months ago
1.0.1
12 months ago
1.0.0
12 months ago
0.2.0
12 months ago
0.1.0
12 months ago