API Documentation
Complete API reference for every class, method, and utility.
NepaliDate
The core date manipulation object — immutable, chainable, inspired by Moment.js. All arithmetic methods return a new instance.
Construction
Date object.NepaliDateNepaliDateNepaliDateNepaliDateGetters
| Property | Type | Description |
|---|---|---|
.year | number | BS year |
.month | number | BS month (1-indexed, 1 = Baisakh) |
.day | number | BS day of month |
.weekDay | number | Day of week (0 = Sunday, 6 = Saturday) |
.quarter | number | Quarter (1–4) |
.dayOfYear | number | Day number within the BS year |
.weekOfYear | number | Week number within the BS year |
.daysInMonth | number | Total days in the current month |
.daysInYear | number | Total days in the current year |
.isLeapYear | boolean | True if the BS year has 366 days |
Conversion
Dateyear, month, day, and weekDay properties.{ year, month, day, weekDay }numberYYYY, MM, DD, MMMM, MMM, dddd, ddd.stringArithmetic
'day', 'week', 'month', 'year'. Returns a new instance.NepaliDate'month', 'year', 'week'.NepaliDate.add(n, unit).NepaliDate.subtract(n, unit).NepaliDateComparison
boolean'day', 'month', or 'year'.boolean'[]', '()', '[)', '(]'.booleanisWeekend() returns true for Saturday (weekDay === 6).boolean'day', 'week', 'month', 'year'.numberCloning & Mutation
NepaliDate'year', 'month', 'day'. Day is clamped to valid range.NepaliDateCalendarEngine
A headless calendar state machine. Holds view state, selection, and disabled-date logic. Zero DOM or framework knowledge — adapters consume its state snapshots.
Constructor Options
| Option | Type | Description |
|---|---|---|
value | NepaliDate | Currently selected date |
defaultDate | NepaliDate | Date to show on first render |
minDate | NepaliDate | Earliest selectable date |
maxDate | NepaliDate | Latest selectable date |
locale | 'en' | 'np' | Display locale (default: 'en') |
weekStartsOn | number | First day of week (0 = Sun, default: 0) |
disabledDays | string[] | Weekday names to disable, e.g. ['Sat'] |
disabledDates | NepaliDate[] | Specific dates to disable |
onChange | Function | Called with NepaliDate on selection |
onMonthChange | Function | Called with { year, month } on navigation |
getState()
Returns a complete, serializable snapshot of the current UI state.
| Property | Type | Description |
|---|---|---|
viewYear | number | Currently displayed BS year |
viewMonth | number | Currently displayed BS month (1-indexed) |
viewMode | 'day' | 'month' | 'year' | Current view mode |
weeks | DayCell[][] | 6 rows × 7 cols of day cells |
months | MonthCell[] | 12 month items for month picker |
years | YearCell[] | ~12 items in current decade window |
selectedDate | NepaliDate | null | Currently selected date |
todayDate | NepaliDate | Today's BS date |
locale | 'en' | 'np' | Current locale |
canGoBack | boolean | Can navigate to previous month |
canGoForward | boolean | Can navigate to next month |
DayCell Shape
| Property | Type |
|---|---|
date | NepaliDate |
label | string — formatted day number |
isToday | boolean |
isSelected | boolean |
isDisabled | boolean |
isOutsideMonth | boolean |
weekDay | number |
Navigation Methods
'day', 'month', and 'year' views.Selection Methods
onChange callback. Skips disabled dates.onChange.Subscriptions
Function — unsubscribe callbackRangePicker
Extends CalendarEngine. Adds two-phase range selection with hover preview.
Additional Options
| Option | Type | Description |
|---|---|---|
startDate | NepaliDate | Initial range start |
endDate | NepaliDate | Initial range end |
minRange | number | Min days between start and end |
maxRange | number | Max days between start and end |
onRangeChange | Function | Called with { start, end } |
Additional State Properties
| Property | Type |
|---|---|
startDate | NepaliDate | null |
endDate | NepaliDate | null |
hoverDate | NepaliDate | null |
selectionPhase | 'idle' | 'start-selected' | 'complete' |
Each DayCell also includes: isRangeStart, isRangeEnd, isInRange, isRangeHover.
Methods
'start-selected' phase).onRangeChange if both dates are set.'idle' phase.Vanilla JS Adapter
Renders the picker into a DOM container and wires events to the engine.
HTMLElement. If the container is an <input>, the picker wraps it automatically.Additional Options
| Option | Type | Description |
|---|---|---|
range | boolean | Use RangePicker instead of CalendarEngine |
inputSelector | string | CSS selector for an input to sync value to |
format | string | Date format string (default: 'YYYY-MM-DD') |
syncInput | boolean | Auto-update the input value on selection |
openOnInit | boolean | Show the panel immediately (default: false) |
Return Value
| Property | Type | Description |
|---|---|---|
engine | CalendarEngine | RangePicker | Direct engine reference |
destroy() | Function | Unmount and clean up all listeners |
open() | Function | Show the picker panel |
close() | Function | Hide the picker panel |
getValue() | Function | Get selected date or range { start, end } |
setValue() | Function | Set value programmatically |
React Adapter
Import from nepali-datepicker/react.
Return Value
| Property | Description |
|---|---|
state | Reactive getState() snapshot |
engine | Direct engine reference |
goToPrevMonth | Bound action |
goToNextMonth | Bound action |
goToPrevYear | Bound action |
goToNextYear | Bound action |
goToToday | Bound action |
setViewMode | Bound action |
selectDate | Bound action |
clearSelection | Bound action |
hoverDate | Bound action (range mode) |
setRange | Bound action (range mode) |
clearRange | Bound action (range mode) |
useNepaliDatePicker to the children render function.Vue 3 Adapter
Import from nepali-datepicker/vue.
ref state. Returns the same interface as the React adapter.{ state: Ref, engine, ...actions }Svelte Adapter
Import from nepali-datepicker/svelte.
$store syntax to access state reactively.{ subscribe, engine, ...actions }Locale & Formatting
Two built-in locales: English ('en') and Nepali Devanagari ('np').
YYYY, MM, DD, MMMM (full month), MMM (short month), dddd (full weekday), ddd (short weekday).stringNepaliDateen and np locale data: months, days, daysLong, today, clear, numberFormat(n).Nepali Month Names
| # | English | Nepali |
|---|---|---|
| 1 | Baisakh | बैशाख |
| 2 | Jestha | जेठ |
| 3 | Ashadh | असार |
| 4 | Shrawan | श्रावण |
| 5 | Bhadra | भाद्र |
| 6 | Ashwin | आश्विन |
| 7 | Kartik | कार्तिक |
| 8 | Mangsir | मंसिर |
| 9 | Poush | पुष |
| 10 | Magh | माघ |
| 11 | Falgun | फाल्गुण |
| 12 | Chaitra | चैत्र |
Converter
Bidirectional conversion between Bikram Sambat and Gregorian dates.
Epoch anchor: 1 Baisakh 2000 BS = April 14, 1943 AD.
{ year, month, day }{ year, month, day }{ [bsYear]: number[12] }. Each array contains the number of days in each month for that year. Range: 2000–2100 BS.Styling
The optional Material stylesheet uses CSS custom properties for full theming control.
Import: import 'nepali-datepicker/dist/material.css'
CSS Custom Properties
| Variable | Default | Description |
|---|---|---|
--ndp-primary | #1976D2 | Primary accent color |
--ndp-primary-dark | #115293 | Darker primary |
--ndp-primary-light | #E3F2FD | Light primary (range bg) |
--ndp-surface | #FFFFFF | Panel background |
--ndp-on-surface | #212121 | Text on surface |
--ndp-on-surface-muted | #757575 | Muted text |
--ndp-radius-md | 8px | Panel border radius |
--ndp-cell-size | 36px | Day cell size |
--ndp-width | 280px | Panel width |
--ndp-font | 'Roboto' | Font family |
--ndp-font-np | 'Noto Sans Devanagari' | Nepali font |
--ndp-transition | 150ms ease | Transition timing |
Component Classes
| Class | Description |
|---|---|
.ndp-container | Outer wrapper |
.ndp-panel | Floating calendar panel |
.ndp-header | Month/year navigation row |
.ndp-grid | 7-column CSS grid for day cells |
.ndp-cell | Individual day cell |
.ndp-cell--today | Today's date indicator |
.ndp-cell--selected | Selected date (filled) |
.ndp-cell--disabled | Disabled cell |
.ndp-cell--range-start | Range start |
.ndp-cell--range-end | Range end |
.ndp-cell--in-range | Days within the selected range |
.ndp-footer | Bottom action bar |
.ndp-input | Input trigger styling |