Socket
Socket
Sign inDemoInstall

react-day-picker

Package Overview
Dependencies
0
Maintainers
1
Versions
230
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-day-picker


Version published
Maintainers
1
Install size
86.9 kB
Created

Package description

What is react-day-picker?

The react-day-picker package is a flexible date picker component for React applications. It allows users to select dates or ranges of dates within a calendar interface. It is customizable and can be used to create various date-picking experiences in web applications.

What are react-day-picker's main functionalities?

Single Date Selection

This feature allows users to select a single date from the calendar. The 'onDayClick' event handler updates the state with the selected date.

import DayPicker from 'react-day-picker';
import 'react-day-picker/lib/style.css';

function MyDatePicker() {
  const [selectedDay, setSelectedDay] = useState();
  return (
    <DayPicker
      selectedDays={selectedDay}
      onDayClick={(day) => setSelectedDay(day)}
    />
  );
}

Range Selection

This feature enables users to select a range of dates. The 'DateUtils.addDayToRange' function is used to update the range state.

import DayPicker, { DateUtils } from 'react-day-picker';
import 'react-day-picker/lib/style.css';

function MyDateRangePicker() {
  const [range, setRange] = useState({ from: undefined, to: undefined });
  const handleDayClick = (day) => {
    const range = DateUtils.addDayToRange(day, this.state.range);
    setRange(range);
  };
  return (
    <DayPicker
      selectedDays={[range.from, { from: range.from, to: range.to }]}
      onDayClick={handleDayClick}
    />
  );
}

Customization

This feature allows for extensive customization of the calendar's appearance and behavior, including custom class names and replacing default components with custom ones.

import DayPicker from 'react-day-picker';
import 'react-day-picker/lib/style.css';

function MyStyledDatePicker() {
  return (
    <DayPicker
      className='my-custom-class'
      weekdayElement={<div>Custom Weekday</div>}
      navbarElement={<div>Custom Navbar</div>}
    />
  );
}

Other packages similar to react-day-picker

Changelog

Source

v1.3.2

Release date: 2016-04-10

Adds React 15 to the peer dependencies.

Readme

Source

title

screen shot

react-day-picker is a flexible date picker component for React.

  • no external dependencies
  • select days, ranges, whatever using CSS modifiers
  • ready for i18n, with moment.js or any other library
  • customizable style
  • navigable via keyboard, ARIA support

Look at some examples showing all its features!

build status coveralls Code Climate npm downloads npm version Bower

How to use

Partecipate

  • Gitter room – ask questions and chat with other developers
  • Issues – file bugs and suggestions
  • Check out the source code on Github
  • Pull requests are welcome! If you are planning a pull request with lot of changes, please add an issue to discuss your idea first
    • See how to start the project locally here

Quick start

Install via npm

npm install react-day-picker --save

and use it in your React components:

import DayPicker from "react-day-picker";

function isSunday(day) {
  return day.getDay() === 0;
}

function MyComponent() {
  return <DayPicker initialMonth={ new Date(2016, 1) } modifiers={{ isSunday }} />
}

If you are not using ES2015, until this is not fixed you should require the module as:

var DayPicker = require("react-day-picker").default

Install via Bower

bower install react-day-picker --save

The bower package exposes a global DayPicker variable.

Keywords

FAQs

Last updated on 10 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc