Code Monkey home page Code Monkey logo

react-datepicker's Introduction

react-datepicker

alt text A cool datepicker for english and persian you can see some features here :

  • You can choosing between 5 colors.
  • Dark mode and Light mode
  • Show loading... and you can change it to whatever you want :)
  • You can use any input component for this datepicker
  • You can set event for days and make them different vs normal days
  • Change your input format
  • Disable some date
  • Set your custom footer for datepicker
  • Auto adjust position
  • Calendar

๐ŸŒŸ If you like this Datepicker, please bookmark it on your github with the star button.

Installation

Use the package manager npm to install @ijavad805/react-datepicker.

npm install @ijavad805/react-datepicker

Usage

import { Datepicker } from '@ijavad805/react-datepicker';
// simple
function AppSimple() {
  return <Datepicker />;
}

// full options
function App() {
  return (
    <Datepicker
      footer={(moment, setValue) => {
        return (
          <>
            <div
              onClick={() => {
                if (setValue) setValue(moment());
              }}
            >
              Today
            </div>
          </>
        );
      }}
      closeWhenSelectADay={true} // boolean
      dayEffects={[
        {
          day: '2022-09-12',
          color: 'red',
          dotColor: 'red',
          title: 'What ever you want',
        },
      ]}
      disabled={false} // disable input
      disabledDate={(day) => day === moment()} // today should be disabled
      format={'YYYY-MM-DD'}
      input={<input placeholder="Select a date" />} // whatever you want
      onOpen={() => {
        console.log('datepicker is open');
      }}
      lang={'en'} // en and fa
      loading={false} // show loading in datepicker if is open
      modeTheme={'dark'} // dark and light
      theme={'blue'} // blue , orange , red , green , yellow
      defaultValue={moment()}
      adjustPosition={'auto'} // auto, right-top, left-top, right-bottom, left-bottom, modal
      onChange={(val: any) => {
        console.log(val.format());
      }}
    />
  );
}

Calendar ( BETA )

The first version of the calendar is ready but it is just v1 and, yes, it may have some bugs. Please report bugs. I will fix it. I am working on design in v2. You will see a beautiful calendar.

en

alt text

fa

alt text

Usage Calendar

const App = () => {
  return (
      <Calendar
         lang = "en"
         theme = "blue"
         events={[
          {
            id: 1, // it should unique
            title: "Test",
            date: "2022-12-27",
            style: {
              // what ever you want
            }
            className: "test",
            dotColor: "#000",
            disabled: false,
            icon: "$", // also you can use component
          }
         ]}
         onDropEvent={(item: IEvent) => {
          console.log(item);
         }}
         onClickEvent={(item: IEvent) => console.log(item)}
         onDoubleClickEvent={(item: IEvent) => console.log(item)}
         style={{
          height: 600
         }}
         onDateClick={(date: moment.Moment) => console.log(date)}
    />
  )
}

Coming soon ...

This is my todo list for feature :

  • Range picker
  • Calender new ui

Report issues

My friend, if you see any bugs, please tell me:

react-datepicker's People

Contributors

ijavad805 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.