Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-flatpickr

Package Overview
Dependencies
Maintainers
2
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-flatpickr

flatpickr for React

  • 3.10.13
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is react-flatpickr?

react-flatpickr is a React wrapper for the flatpickr date picker library. It provides a highly customizable and lightweight date picker component for React applications.

What are react-flatpickr's main functionalities?

Basic Date Picker

This code demonstrates a basic date picker with time selection enabled. The selected date is stored in the component's state.

import React from 'react';
import Flatpickr from 'react-flatpickr';
import 'flatpickr/dist/themes/material_green.css';

const BasicDatePicker = () => {
  const [date, setDate] = React.useState(new Date());
  return (
    <Flatpickr data-enable-time
      value={date}
      onChange={date => setDate(date)}
    />
  );
};

export default BasicDatePicker;

Range Date Picker

This code demonstrates a range date picker where users can select a start and end date. The selected range is stored in the component's state.

import React from 'react';
import Flatpickr from 'react-flatpickr';
import 'flatpickr/dist/themes/material_green.css';

const RangeDatePicker = () => {
  const [date, setDate] = React.useState([new Date(), new Date()]);
  return (
    <Flatpickr
      options={{ mode: 'range' }}
      value={date}
      onChange={date => setDate(date)}
    />
  );
};

export default RangeDatePicker;

Custom Date Format

This code demonstrates a date picker with a custom date format. The date format is set to 'Y-m-d H:i' (Year-Month-Day Hour:Minute).

import React from 'react';
import Flatpickr from 'react-flatpickr';
import 'flatpickr/dist/themes/material_green.css';

const CustomDateFormat = () => {
  const [date, setDate] = React.useState(new Date());
  return (
    <Flatpickr
      options={{ dateFormat: 'Y-m-d H:i' }}
      value={date}
      onChange={date => setDate(date)}
    />
  );
};

export default CustomDateFormat;

Other packages similar to react-flatpickr

Keywords

FAQs

Package last updated on 27 Jun 2022

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc