4.0.2 • Published 12 months ago

@dchimen/react-datepicker v4.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
12 months ago

React Datepicker

A simple datepicker component for React. Features localisation, responsive layout, customisable styling and a simple API. It is built with Typescript, TailwindCSS, date-fns, weekstart and zustand. See it in action.


Installation

The package can be installed via npm:

npm install @dchimen/react-datepicker --save

Or via pnpm:

pnpm add @dchimen/react-datepicker

Or via yarn:

yarn add @dchimen/react-datepicker

Requirements

The only required dependency for the datepicker to work is React.


Minimum configuration

You must provide a child text input field to the datepicker.

import Datepicker from '@dchimen/react-datepicker';
import '@dchimen/react-datepicker/react-datepicker.css';

export default function App() {
  return (
    <Datepicker>
      <input type="text"></input>
    </Datepicker>
  );
}

You may provide additional options like so:

<Datepicker
  startDate={startDate}
  endDate={endDate}
  onDateChange={(selectedStartDate, selectedEndDate) => {
    setStartDate(selectedStartDate);
    setEndDate(selectedEndDate);
  }}
/>

Options

OptionRequired typeDescriptionDefault
startDateDateSpecify an active dateDate()
startLabelstringSpecify a label for the startDate''
endDateDateThis creates a range between the startDate and the specified endDatenull
endLabelstringSpecify a label for the endDate''
minDateDateThe minimum selectable datenull
maxDateDateThe maximum selectable datenull
titlestringRenders a custom title''
showOtherMonthsBooleanWhen true former and latter date cells are rendered within each calendarfalse
showWeekNumbersBooleanWhen true ISO week numbers will be displayedfalse
closeOnSelectBooleanWhen true and dates are selected, the datepicker will close immediatelyfalse
disabledDatesDate[]Disable specific dates[]
labelsSee ExampleSpecify labels for specific datesnull
localestringSets custom localisationen-GB
themeSee ExamplePass custom CSS classes to the datepickernull
onOpenFunctionA callback function called when the datepicker has been openedvoid
onCloseFunctionA callback function called when the datepicker has been closedvoid
onDateSelectFunctionA callback function called when a date has been selected. The startDate and endDate parameters are returned.void
onDateChangeFunctionA callback function called when the dates have been changed. The startDate and endDate parameters are returned.void

License

Copyright (c) 2023 Daniel Chimen and individual contributors. Licensed under MIT license, see the LICENSE file included for details.

3.0.1

1 year ago

3.0.0

1 year ago

4.0.1

1 year ago

4.0.0

1 year ago

4.0.2

12 months ago

1.8.2

1 year ago

1.9.0

1 year ago

1.8.1

1 year ago

1.8.0

1 year ago

1.7.0

1 year ago

1.6.0

1 year ago

2.0.3

1 year ago

2.1.1

1 year ago

2.0.2

1 year ago

1.8.5

1 year ago

1.8.4

1 year ago

1.8.3

1 year ago

2.1.0

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.5.1

1 year ago

1.5.0

1 year ago

1.4.0

1 year ago

1.3.0

1 year ago

1.2.0

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago