Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
react-day-picker
Advanced tools
Package description
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.
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>}
/>
);
}
react-datepicker is a comprehensive date picker library for React. It offers similar functionalities to react-day-picker, such as single date selection, range selection, and customization options. It also provides additional features like time selection and predefined date ranges.
material-ui-pickers is a set of components that implement Material Design pickers for date and time in React. It integrates well with Material-UI and offers a different look and feel compared to react-day-picker, with similar functionality for date selection.
antd, or Ant Design, is a UI design language and React UI library that includes a DatePicker component. It offers a wide range of features and is designed to work within the Ant Design system, providing a different user experience compared to react-day-picker.
Changelog
v8.4.1
Release date: 2022-12-17
onDayPointerEnter
, onDayPointerLeave
propsReadme
React DayPicker is a date picker component for React. Renders a calendar where the user can browse months to select days. DayPicker is customizable, works great with input fields and can be styled to match any design.
➡️ react-day-picker.js.org for guides, examples and API reference.
npm install react-day-picker date-fns # using npm
pnpm install react-day-picker date-fns # using pnpm
yarn add react-day-picker date-fns # using yarn
import React from 'react';
import { format } from 'date-fns';
import { DayPicker } from 'react-day-picker';
import 'react-day-picker/dist/style.css';
export default function Example() {
const [selected, setSelected] = React.useState<Date>();
let footer = <p>Please pick a day.</p>;
if (selected) {
footer = <p>You picked {format(selected, 'PP')}.</p>;
}
return (
<DayPicker
mode="single"
selected={selected}
onSelect={setSelected}
footer={footer}
/>
);
}
See react-day-picker.js.org for guides, examples and API reference of the latest version. Docs for version 7 are at react-day-picker-v7.netlify.app.
FAQs
Customizable Date Picker for React
The npm package react-day-picker receives a total of 1,351,769 weekly downloads. As such, react-day-picker popularity was classified as popular.
We found that react-day-picker demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.