1.1.1 • Published 5 months ago

react-native-customdob v1.1.1

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

DOBPicker

DOBPicker is a customizable Date of Birth picker component for React Native, built using react-native-paper and react-native-modal-datetime-picker. It allows users to select a date and time using a modal date picker, with additional support for custom icons and text input handling.

Installation

Ensure you have react-native-paper and react-native-modal-datetime-picker installed in your project. If not, install them first:

npm install react-native-paper react-native-modal-datetime-picker date-fns

Then, install DOBPicker by adding it to your project:

npm install react-native-customtextinput

Usage

Import and use the DOBPicker component in your React Native project:

import React, { useState } from 'react';

import { View, Image } from 'react-native';

import DOBPicker from 'react-native-customtextinput';

const App = () => {

const selectedDate, setSelectedDate = useState<Date | undefined>();

return (

<View style={{ padding: 20 }}>

  <DOBPicker
    label="Date of Birth"
    onDateChange={handleDateChange}
    dateFormat="yyyy-MM-dd"
    calendarIcon={require('./assets/calendar.png')}
    clearIcon={require('./assets/clear.png')}
    rightCalendarIconStyle={{ width: 30, height: 30, tintColor: 'blue' }}
    Icon={require('./assets/user.png')}
    leftIconStyle={{ width: 25, height: 25, tintColor: 'green' }}
  />
  
</View>

); };

export default App;

Props

Prop NameTypeDefaultDescription
labelstringundefinedLabel for the text input field.
valuestringundefinedThe value displayed in the input field.
IconImageSourcePropTypeundefinedOptional left-side icon.
calendarIconImageSourcePropTypeRequiredCalendar icon for the date picker.
clearIconImageSourcePropTypeundefinedClear icon to reset the selected date.
onDateChange(selectedDate: Date / undefined) => voidRequiredCallback when the date is selected or cleared.
dateFormatstring'dd/MM/yyyy h:mm'Format for displaying the selected date.
onClear() => voidundefinedCallback when the clear button is pressed.
returnKeyType'done' / 'next'undefinedReturn key type for the keyboard.
onSubmitEditing() => voidundefinedCallback when submitting the input field.
forwardRefRef<RNTextInput>undefinedForwarded reference to the input field.
textColorstring'black'Color of the text in the input field.
placeholderTextColorstring'black'Color of the placeholder text.
mode'flat' / 'outlined''outlined'Mode of the TextInput component from react-native-paper.
rightCalendarIconStyleStyleProp<ImageStyle>undefinedStyle for the right calendar/clear icon.
leftIconStyleStyleProp<ImageStyle>undefinedStyle for the left icon.
datetimeMode'date' / 'time' / 'datetime''datetime'Mode for the DateTimePickerModal (date, time, or datetime).

Features

Displays a modal date and time picker.

Customizable icons for calendar and clear actions.

Prevents direct text input to ensure valid date selection.

Uses date-fns for date formatting and parsing.

Supports React Native Paper's theming.

1.1.1

5 months ago

1.1.0

5 months ago

1.0.9

5 months ago

1.0.8

5 months ago

1.0.7

5 months ago

1.0.6

5 months ago

1.0.5

5 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.0

5 months ago