react-nepali-date-picker-lite
v1.2.0
Published
## Introduction
Downloads
67
Maintainers
Readme
react-nepali-date-picker-lite
Introduction
React Nepali Date Picker is a widget for react , this is a typical calendar picker , it is very light weight and can be intigrated with your own styling component
Installation
npm i react-nepali-date-picker-lite
Parameters
Calendar can be used to act as an input component as well. All the parameters are optional. And also can pass custom inpt component as children
- value : send the date from which to show calendar with else default is the current date. Date must be in 'YYY-MM-DD' format currently only one format is supported.
- onSelect : returns the value that has been selected or the date that user has clicked on
- inputprops: props for input element for using define input element.
- className: class for root container.
- renderinput: to render custom input field.
Demo
commands to run demo app
npm
cd app
npm run dev
NepaliDateConverter
it is the group of function which convert dates between Bs,Ad and many more.
- BsAddDays(date,day)
- BsDatesDiff(date,date)
- getMonths
- getNepaliMonths
- getNepaliMonthsInNepali
- getNepaliMonth(0-11)
- getCurrentDayName
- getDaynumberFromBsDate(date)
- AD2BS(ad format date)
- BS2AD(bs format date)
- getNepaliDate
- getDateInWords
- getAdDateInWords(date)
- getNepaliDateInWords(date)
- getCurrentYear
- getCurrentMonth
- getCurrentDay
- getCurrentBsyear
- getCurrentBsmonth
- getCurrentBsday
- getBsyear(date)
- getBsmonth(date)
- getBsday(date)
Styling
Add this to your application css to change datepicker styling, use this to change width, font color and background color of the datepicker in your app.
.picker-container: the main container of the datepicker that wraps everything, add background color to the datepicker
.daybutton: this is the container for actual date of a day in the datepicker such as 1,2,3, 4, ....
.dayselected: css for the date that was actually selected
.daynormal: css too give hovver effect on normal days
.today: css to style today date
.picker-header-container: it is the container of datepicker header where header or located. ef:- prevbtn, nextbtn, yearselect....
.prev-btn: css for previous button.
.next-btn: css for next button.
.month-select: css for select element of month.
.year-select: css for select element of year.
.datepicker-select: css for select element.
Usage
For pre defined input field
import React, { useState } from "react";
import {
NepaliDateConverter,
NepaliDatePicker,
} from "react-nepali-date-picker-lite";
function App() {
const today = NepaliDateConverter.getNepaliDate();
const [value, setValue] = useState(today);
return <NepaliDatePicker value={value} onSelect={setValue} />;
}
export default App;
For self Defined Input field
import React, { useState } from "react";
import {
NepaliDateConverter,
NepaliDatePicker,
} from "react-nepali-date-picker-lite";
function App() {
const today = NepaliDateConverter.getNepaliDate();
const [value, setValue] = useState(today);
return (
<NepaliDatePicker
value={value}
onSelect={setValue}
renderInput={(props) => <input type="text" {...props} />}
/>
);
}
export default App;