Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

a cool datepicker

NotificationsYou must be signed in to change notification settings

ijavad805/react-datepicker

Repository files navigation

alt text

NPM VersionNPM Downloadsnpm bundle size

A cool datepicker and calendar 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

alt text

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

Installation

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

npm install @ijavad805/react-datepicker

Usage

import{Datepicker}from'@ijavad805/react-datepicker';// simplefunctionAppSimple(){return<Datepicker/>;}// full optionsfunctionApp(){return(<Datepickerfooter={(moment,setValue)=>{return(<><divonClick={()=>{if(setValue)setValue(moment());}}>              Today</div></>);}}closeWhenSelectADay={true}// booleandayEffects={[{day:'2022-09-12',color:'red',dotColor:'red',title:'What ever you want',},]}disabled={false}// disable inputdisabledDate={(day)=>day===moment()}// today should be disabledformat={'YYYY-MM-DD'}input={<inputplaceholder="Select a date"/>}// whatever you wantonOpen={()=>{console.log('datepicker is open');}}lang={'en'}// en and faloading={false}// show loading in datepicker if is openmodeTheme={'dark'}// dark and lighttheme={'blue'}// blue , orange , red , green , yellowdefaultValue={moment()}adjustPosition={'auto'}// auto, right-top, left-top, right-bottom, left-bottom, modalonChange={(val:any)=>{console.log(val.format());}}/>);}

Calendar ( VERSION 1 )Demo

Calendar Properties

The Calendar props interface provides configuration options for customizing the behavior and appearance of thereact-datepicker component. Here's a summary of its properties:

PropertyTypeDescription
lang"en" | "fa"Language for the calendar. Either "en" for English or "fa" for Farsi (Persian).
theme"blue"Theme for the calendar. Currently, only "blue" is supported.
eventsIEvent[]An array ofIEvent objects representing the events to be displayed on the calendar.
onDay(date: string) => { className?: string; }A function to customize the appearance of a day. It takes a date string as input and should return an object with an optionalclassName property to apply custom styles.
disabledDate(date: moment.Moment) => booleanA function that determines whether a date should be disabled. It takes a Moment.js date object as input and should returntrue to disable the date orfalse to enable it.
onClickEvent(item: IEvent) => voidA function to handle event click events. It receives anIEvent object as its argument.
onDoubleClickEvent(item: IEvent) => voidA function to handle event double-click events. It receives anIEvent object as its argument.
onDropEvent(item: IEvent) => voidA function to handle event drop events. It receives anIEvent object as its argument, to enable drag and drop functionality, this prop should not beundefined
onDateClick(date: string) => voidA function to handle date click events. It receives a date string as its argument.
onMonthChange(start: string, end: string) => voidA function to handle month change events. It receives two date strings,start andend, indicating the new visible date range on the calendar.
styleReact.CSSPropertiesAdditional CSS styles to apply to the calendar component.
allowClearbooleanallow user to clear the value

These properties allow you to configure and customize the behavior and appearance of theCalendar component in your application.

IEvent Interface

TheIEvent interface represents an individual event that can be displayed on the calendar. It provides details about the event. Here's a summary of its properties:

PropertyTypeDescription
idnumberA unique identifier for the event.
titleReact.ReactNode | stringThe title of the event, which can be either a Component or a string.
dateDateEventThe date of the event, which can be a date string or an object withstart andend properties.
styleReact.CSSPropertiesAdditional CSS styles for the event.
classNamestringAdditional CSS class for the event.
dotColorstringColor for a dot associated with the event.
disabledbooleanA flag indicating if the event is disabled.
iconReact.ReactNodeA React node for an icon associated with the event.

These properties allow you to specify the details and appearance of events to be displayed on the calendar.

constApp=()=>{return(<Calendarlang="en"theme="blue"events={[{id:1,// it should uniquetitle:'Test',date:'2023-09-16',className:'test',dotColor:'#000',disabled:false,icon:'$',// also you can use componentstyle:{// what ever you want},},]}onDropEvent={(item:IEvent)=>{// for enabling drag and drop option you should pass this functionconsole.log(item);}}onClickEvent={(item:IEvent)=>console.log(item)}onDoubleClickEvent={(item:IEvent)=>console.log(item)}style={{height:600,}}onDateClick={(date:moment.Moment)=>console.log(date)}/>);};

Report issues

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

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp