Gathering detailed insights and metrics for react-flatpickr
Gathering detailed insights and metrics for react-flatpickr
Gathering detailed insights and metrics for react-flatpickr
Gathering detailed insights and metrics for react-flatpickr
npm install react-flatpickr
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
603 Stars
142 Commits
103 Forks
5 Watching
6 Branches
33 Contributors
Updated on 19 Nov 2024
Minified
Minified + Gzipped
JavaScript (97.82%)
HTML (2.18%)
Cumulative downloads
Total Downloads
Last day
5.8%
25,432
Compared to previous day
Last week
9.6%
140,536
Compared to previous week
Last month
6.2%
578,525
Compared to previous month
Last year
34.9%
6,705,542
Compared to previous year
2
1
35
Flatpickr for React.
This package can be install with yarn
or npm
npm
1npm install --save react-flatpickr
yarn
1yarn add react-flatpickr
1// Keep in mind that these are the styles from flatpickr package 2// See troubleshooting section in case you have problems importing the styles 3 4import "flatpickr/dist/themes/material_green.css"; 5 6import Flatpickr from "react-flatpickr"; 7import { Component } from "react"; 8 9class App extends Component { 10 constructor() { 11 super(); 12 13 this.state = { 14 date: new Date() 15 }; 16 } 17 18 render() { 19 const { date } = this.state; 20 return ( 21 <Flatpickr 22 data-enable-time 23 value={date} 24 onChange={([date]) => { 25 this.setState({ date }); 26 }} 27 /> 28 ); 29 } 30}
string
| optional
This is the default value that will be passed to the inner input
string || array || object || number
| optional
Same as below
Object
| optional
Flatpickr options
: you can pass all Flatpickr parameters
here.Flatpickr
hooks can be passed within this option too.Example:
1<Flatpickr options={{ minDate: "2017-01-01" }} />
node
| optional
This option is closely related with the wrap option from Flatpickr
, please refer to the former link for more information.
string
| optional
Custom className that will be applied to the inner input
element. In case you need to modify the rendered input
styles this is the prop
you should use.
The following props
are provided in order to customize the Flatpickr's functions
default behaviour. Please refer to the Events & Hooks section from Flatpickr
library.
function
| optional
function
| optional
function
| optional
function
| optional
function
| optional
function
| optional
function
| optional
function
| optional
function
| optional
function
| optional
Use this prop
if you want to render
your custom component, this is a Render props pattern.
Example usage:
1 import React from 'react'; 2 import Flatpickr from 'react-flatpickr'; 3 4 const CustomInput = ({ value, defaultValue, inputRef, ...props }) => { 5 return <input {...props} defaultValue={defaultValue} ref={inputRef} />; 6 }; 7 8 export default function App { 9 return ( 10 <Flatpickr 11 render={ 12 ({defaultValue, value, ...props}, ref) => { 13 return <CustomInput defaultValue={defaultValue} inputRef={ref} /> 14 } 15 } 16 /> 17 ) 18 }
You can directly manipulate the flatpickr
instance using the flatpickr
property on the component.
Example:
1 import React, { useRef } from "react"; 2 import Flatpickr from "react-flatpickr"; 3 4 import "flatpickr/dist/flatpickr.css"; 5 6 export default function App() { 7 const fp = useRef(null); 8 9 return ( 10 <div> 11 <Flatpickr ref={fp} /> 12 <button 13 type="button" 14 onClick={() => { 15 if (!fp?.current?.flatpickr) return; 16 fp.current.flatpickr.clear(); 17 }} 18 > 19 Clear 20 </button> 21 </div> 22 ); 23 }
Please import themes directly from the flatpickr
dependency.
In most cases, you should just be able to
import 'flatpickr/dist/themes/airbnb.css'
, but in some cases npm or yarn may installflatpickr
innode_modules/react-flatpickr/node_modules/flatpickr
. If that happens, removing yournode_modules
dir and reinstalling should put flatpickr in the rootnode_modules
dir, or you can import fromreact-flatpickr/node_modules/flatpickr
manually.
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 4/17 approved changesets -- score normalized to 2
Reason
2 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 1
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
40 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More