2.0.2 • Published 3 months ago

react-native-ui-datepicker v2.0.2

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

react-native-ui-datepicker


react-native-ui-datepicker

styled with prettier license

DateTimePicker component for React Native that allows you to create a customizable date and time picker. The component uses Day.js library and it contains a set of style props that allows you to change every item of calendar based on your own UI design. Please visit demo.

Installation

npm install react-native-ui-datepicker

Or

yarn add react-native-ui-datepicker

Usage

import DateTimePicker from 'react-native-ui-datepicker';
import dayjs from 'dayjs';

export default function App() {
  const [date, setDate] = useState(dayjs());

  return (
    <View style={styles.container}>
      <DateTimePicker
        mode="single"
        date={date}
        onChange={(params) => setDate(params.date)}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#F5FCFF',
  },
});

For more, take a look at the /example directory.

react-native-ui-datepicker-styles

Calendar props

NameTypeDefaultDescription
modestring'single'Defines the DatePicker mode ['single', 'range', 'multiple']
localestring'en'Defines the DatePicker locale
minDateDateTypenullDefines DatePicker minimum selectable date
maxDateDateTypenullDefines DatePicker maximum selectable date
firstDayOfWeeknumber0Defines the starting day of week, number 0-6, 0 - Sunday, 6 - Saturday
displayFullDaysbooleanfalseDefines show previous and next month's days in the current calendar view
initialViewstring'day'Defines the DatePicker initial view ['day', 'month', 'year', 'time']
heightnumber'undefined'Defines the Calendar view heights

Single Mode props

NameTypeDefaultDescription
dateDateTypeundefinedDate value to display selected date
onChangeFunction({date}) => {}Called when the new date selected from DatePicker
timePickerbooleanfalseDefines show or hide time picker

Range Mode props

NameTypeDefaultDescription
startDateDateTypeundefinedStart date value to display selected start date
endDateDateTypeundefinedEnd date value to display selected end date
onChangeFunction({startDate, endDate}) => {}Called when the new start or end date selected from DatePicker

Multiple Mode props

NameTypeDefaultDescription
datesDateType[][]Dates array to display selected dates
onChangeFunction({dates}) => {}Called when the new dates selected from DatePicker

Styling props

NameTypeDefaultDescription
calendarTextStyleTextStylenullDefines all text styles inside the calendar (Days, Months, Years, Hours, and Minutes)
selectedTextStyleTextStylenullDefines selected (Day, Month, Year) text styles
selectedItemColorstring'#0047FF'Defines selected (Day, Month, Year) background and border colors
headerContainerStyleViewStylenullDefines calendar header container style
headerTextContainerStyleViewStylenullDefines calendar header texts (Month, Year, Time) containers style
headerTextStyleTextStylenullDefines calendar header text styles (Month, Year, Time)
headerButtonStyleViewStylenullDefines calendar header "prev and next buttons" containers style
headerButtonColorstringnullDefines calendar header "prev and next buttons" icon color
headerButtonSizenumber18Defines calendar header "prev and next buttons" icon size
headerButtonsPositionstring'around'Defines calendar header "prev and next buttons" positions ['around', 'right', 'left']
buttonPrevIconReactNodeundefinedDefines calendar header "prev button" custom icon
buttonNextIconReactNodeundefinedDefines calendar header "next button" custom icon
dayContainerStyleViewStylenullDefines days containers style
todayContainerStyleViewStylenullDefines today container style
todayTextStyleTextStylenullDefines today text style
monthContainerStyleViewStylenullDefines months containers style
yearContainerStyleViewStylenullDefines years containers style
weekDaysContainerStyleViewStylenullDefines weekdays container style
weekDaysTextStyleTextStylenullDefines weekdays texts style
timePickerContainerStyleViewStylenullDefines time picker container style
timePickerTextStyleTextStylenullDefines time picker (Hours, Minutes) texts style

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

Consider supporting with a ⭐️ Star on GitHub

If you are using the library in one of your projects, please consider supporting it with a star.

License

MIT