All Projects → haoxins → React Flatpickr

haoxins / React Flatpickr

Licence: mit
flatpickr for React

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Flatpickr

Tlroadmap
Тимлид – это ❄️, потому что в каждой компании он уникален и неповторим.
Stars: ✭ 4,398 (+897.28%)
Mutual labels:  hacktoberfest
Math Worksheet Generator
Create basic addition, subtraction, multiplication and division practice questions with the answer sheet
Stars: ✭ 438 (-0.68%)
Mutual labels:  hacktoberfest
Matter
Customizable GRUB theme inspired by Material Design
Stars: ✭ 439 (-0.45%)
Mutual labels:  hacktoberfest
Flame
A minimalist Flutter game engine
Stars: ✭ 5,543 (+1156.92%)
Mutual labels:  hacktoberfest
Tania Core
Tania is a farm management software to help farmers manage their farm operations.
Stars: ✭ 432 (-2.04%)
Mutual labels:  hacktoberfest
Ritchie Cli
Ritchie CLI is an open-source tool that allows to create, store and share any kind of automation, executing them through command lines, to run operations or start workflows ⚙️ 🖥 💡
Stars: ✭ 437 (-0.91%)
Mutual labels:  hacktoberfest
Jackson Module Scala
Add-on module for Jackson (https://github.com/FasterXML/jackson) to support Scala-specific datatypes
Stars: ✭ 431 (-2.27%)
Mutual labels:  hacktoberfest
Libretime
LibreTime: Radio Broadcast & Automation Platform
Stars: ✭ 439 (-0.45%)
Mutual labels:  hacktoberfest
Product Is
Welcome to the WSO2 Identity Server source code! For info on working with the WSO2 Identity Server repository and contributing code, click the link below.
Stars: ✭ 435 (-1.36%)
Mutual labels:  hacktoberfest
Check postgres
Nagios check_postgres plugin for checking status of PostgreSQL databases
Stars: ✭ 438 (-0.68%)
Mutual labels:  hacktoberfest
Graphqlmap
GraphQLmap is a scripting engine to interact with a graphql endpoint for pentesting purposes.
Stars: ✭ 434 (-1.59%)
Mutual labels:  hacktoberfest
Svelte I18n
Internationalization library for Svelte
Stars: ✭ 433 (-1.81%)
Mutual labels:  hacktoberfest
Monk object detection
A one-stop repository for low-code easily-installable object detection pipelines.
Stars: ✭ 437 (-0.91%)
Mutual labels:  hacktoberfest
Unform
Performance-focused API for React forms 🚀
Stars: ✭ 4,340 (+884.13%)
Mutual labels:  hacktoberfest
Quaternion
A Qt5-based IM client for Matrix
Stars: ✭ 438 (-0.68%)
Mutual labels:  hacktoberfest
Npkill
List any node_modules directories in your system, as well as the space they take up. You can then select which ones you want to erase to free up space.
Stars: ✭ 5,325 (+1107.48%)
Mutual labels:  hacktoberfest
Geofirestore Js
Location-based querying and filtering using Firebase Firestore.
Stars: ✭ 436 (-1.13%)
Mutual labels:  hacktoberfest
Badge Poser
The PHP badges, renders some badges for your readme with the packagist information.
Stars: ✭ 440 (-0.23%)
Mutual labels:  hacktoberfest
Express Openapi Validator
🦋 Auto-validates api requests, responses, and securities using ExpressJS and an OpenAPI 3.x specification
Stars: ✭ 436 (-1.13%)
Mutual labels:  hacktoberfest
Glorytun
Multipath UDP tunnel
Stars: ✭ 437 (-0.91%)
Mutual labels:  hacktoberfest

NPM version License Dependency status

react-flatpickr

Flatpickr for React.

Table of contents

Installation

This package can be install with yarn or npm

npm

npm install --save react-flatpickr

yarn

yarn add react-flatpickr

Usage

// Keep in mind that these are the styles from flatpickr package
// See troubleshooting section in case you have problems importing the styles

import "flatpickr/dist/themes/material_green.css";

import Flatpickr from "react-flatpickr";
import { Component } from "react";

class App extends Component {
  constructor() {
    super();

    this.state = {
      date: new Date()
    };
  }

  render() {
    const { date } = this.state;
    return (
      <Flatpickr
        data-enable-time
        value={date}
        onChange={date => {
          this.setState({ date });
        }}
      />
    );
  }
}

Basic props

defaultValue

string | optional

This is the default value that will be passed to the inner input

value

string || array || object || number | optional

Same as below

options

Object | optional

  • Flatpickr options: you can pass all Flatpickr parameters here.
  • All Flatpickr hooks can be passed within this option too.

Example:

<Flatpickr options={{ minDate: "2017-01-01" }} />

children

node | optional

This option is closely related with the wrap option from Flatpickr, please refer to the former link for more information.

className

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.

Event handlers

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.

onChange

function | optional

onOpen: function

function | optional

onClose: function

function | optional

onMonthChange: function

function | optional

onYearChange: function

function | optional

onReady: function

function | optional

onValueUpdate: function

function | optional

onDayCreate: function

function | optional

onDestroy: function

function | optional

Advanced props

render

function | optional

Use this prop if you want to render your custom component, this is a Render props pattern.

Example usage:

  import React from 'react';
  import Flatpickr from 'react-flatpickr';

  const CustomInput = ({ value, defaultValue, inputRef, ...props }) => {
    return <input {...props} defaultValue={defaultValue} ref={inputRef} />;
  };

  export default function App {
    return (
      <Flatpickr
        render={
          ({defaultValue, value, ...props}, ref) => {
            return <CustomInput defaultValue={defaultValue} inputRef={ref} />
          }
        }
      />
    )
  }

Themes

Please import themes directly from the flatpickr dependency.

Troubleshooting

Help, the Date Picker doesn't have any styling!

In most cases, you should just be able to import 'flatpickr/dist/themes/airbnb.css', but in some cases npm or yarn may install flatpickr in node_modules/react-flatpickr/node_modules/flatpickr. If that happens, removing your node_modules dir and reinstalling should put flatpickr in the root node_modules dir, or you can import from react-flatpickr/node_modules/flatpickr manually.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].