2.4.1 • Published 5 months ago

@s77rt/react-native-date-picker v2.4.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

Features

  • šŸ“… Date picker
  • šŸ•œ Time picker
  • šŸ—“ļø Datetime picker
  • šŸŒ™ Yearmonth picker
  • šŸ”Œ Supports iOS, Android and Web
  • šŸ’Ž Renders in modal and inline
  • ✨ Highly customizable

Screenshots

iOSAndroidmWeb - SafarimWeb - ChromeWeb - Chrome

https://github.com/user-attachments/assets/f46f5132-3385-48c9-8d1b-ee478b60fba8

Installation

  • Using npm

    npm install @s77rt/react-native-date-picker
  • Using yarn

    yarn 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.

PropTypeDescription
refRef<DatePickerHandle>Ref for the date picker handle.
typeTypeThe type of the picker.
valueDate \| nullThe selected date.
onChange(value: Date \| null) => voidCallback when the user changes the selected date.
minDateThe earliest selectable date.
maxDateThe latest selectable date.
stepnumberThe stepping interval, in seconds. āš«šŸ”µ
inlinebooleanWhether the date picker should be displayed inline. ⚫🟢
optionsOptionsOptions. Note: Must be memoized (useMemo). ⚫🟢
stylesStylesStyles. Note: Must be memoized (useMemo). ⚫🟢

Type

The type of the picker and can be one of the following:

  • date
  • time
  • datetime āš«šŸ”µ
  • yearmonth āš«šŸ”µ

Options

Various configuration options.

OptionTypeDescription
localestringThe locale BCP-47 identifier. ⚫
confirmTextstringThe confirm button text. ⚫🟢
cancelTextstringThe cancel button text. ⚫🟢
mode"compact" \| "graphical" \| "wheel"The display mode. ⚫
titlestringThe title. 🟢
headlinestringThe headline. 🟢
showModeTogglebooleanWhether the mode toggle should be shown. 🟢
is24HourbooleanWhether the time should be in 24-hour. 🟢

Styles

Look and feel styles.

StyleTypeDescription
accentColorColorValueThe accent color. ⚫
containerColorColorValueThe container color. 🟢
titleContentColorColorValueThe title color. 🟢
headlineContentColorColorValueThe headline color. 🟢
weekdayContentColorColorValueThe weekday letters color. 🟢
subheadContentColorColorValueThe month and year subhead labels color. 🟢
navigationContentColorColorValueThe year and arrow buttons color. 🟢
yearContentColorColorValueThe year color. 🟢
disabledYearContentColorColorValueThe disabled year color. 🟢
currentYearContentColorColorValueThe current year color. 🟢
selectedYearContentColorColorValueThe selected year color. 🟢
disabledSelectedYearContentColorColorValueThe disabled selected year color. 🟢
selectedYearContainerColorColorValueThe selected year container color. 🟢
disabledSelectedYearContainerColorColorValueThe disabled selected container color. 🟢
dayContentColorColorValueThe day color. 🟢
disabledDayContentColorColorValueThe disabled day color. 🟢
selectedDayContentColorColorValueThe selected day color. 🟢
disabledSelectedDayContentColorColorValueThe disabled selected day color. 🟢
selectedDayContainerColorColorValueThe selected day container color. 🟢
disabledSelectedDayContainerColorColorValueThe disabled selected day container color. 🟢
todayContentColorColorValueThe today color. 🟢
todayDateBorderColorColorValueThe today border color. 🟢
dayInSelectionRangeContainerColorColorValueThe selected days container color. 🟢
dayInSelectionRangeContentColorColorValueThe selected days color. 🟢
dividerColorColorValueThe divider color. 🟢
clockDialColorColorValueThe clock dial color. 🟢
selectorColorColorValueThe clock dial selector color. 🟢
periodSelectorBorderColorColorValueThe period selector border color. 🟢
clockDialSelectedContentColorColorValueThe selected number color. 🟢
clockDialUnselectedContentColorColorValueThe unselected number color. 🟢
periodSelectorSelectedContainerColorColorValueThe selected period container color. 🟢
periodSelectorUnselectedContainerColorColorValueThe unselected period container color. 🟢
periodSelectorSelectedContentColorColorValueThe selected period color. 🟢
periodSelectorUnselectedContentColorColorValueThe unselected period color. 🟢
timeSelectorSelectedContainerColorColorValueThe selected time container color. 🟢
timeSelectorUnselectedContainerColorColorValueThe unselected time container color. 🟢
timeSelectorSelectedContentColorColorValueThe selected time color. 🟢
timeSelectorUnselectedContentColorColorValueThe unselected time color. 🟢

Methods

Imperative handle methods.

MethodTypeDescription
showPicker() => voidShows the picker.

Feedback

Every code review, bug report and feature request is appreciated! Please feel free to share your feedback.

License

MIT


⚫ iOS - 🟢 Android - šŸ”µ Web

2.4.1

5 months ago

2.4.0

5 months ago

2.3.2

5 months ago

2.3.1

5 months ago

2.3.0

5 months ago

2.2.2

5 months ago

2.2.1

5 months ago

2.2.0

5 months ago

2.1.0

6 months ago

2.0.1

6 months ago

2.0.0

6 months ago

1.4.0

6 months ago

1.3.0

6 months ago

1.2.0

6 months ago

1.1.0

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago

0.2.0

6 months ago

0.1.0

6 months ago