logo
DocsAPI Reference

API Reference

This page documents the complete public API for nepali-bs-calendar-react v1.0.0.

Props

PropTypeDefaultDescription
valuestring | nullnullCurrent selected BS date in YYYY-MM-DD format.
onChange(value: string, date: NepaliDateValue) => void-Callback triggered when a date is selected.
minDatestring-Minimum selectable BS date in YYYY-MM-DD format.
maxDatestring-Maximum selectable BS date in YYYY-MM-DD format.
disabledDatesstring[][]Specific disabled BS dates in YYYY-MM-DD format.
isDateDisabled(date: NepaliDateValue) => boolean-Custom function to disable a date.
labelstring-Label displayed above the picker.
placeholderstringSelect datePlaceholder text when no date is selected.
calendarComponentReact.ComponentType<NepaliCalendarViewRenderProps>-Custom calendar component that receives internal calendar state, actions, and helper values.
renderCalendar(props: NepaliCalendarViewRenderProps) => React.ReactNode-Render prop alternative for custom calendar markup.
disabledbooleanfalseDisables the picker.
errorstring-Error message shown below the picker.
touchedbooleanfalseShows error only when touched is true.
classNamestring""Extra class name added to the main wrapper.

Type Reference

type NepaliDateValue = {
  year: number
  month: number
  day: number
}

onChange Callback Shape

<NepaliCalendar
  value={date}
  onChange={(value, dateObject) => {
    console.log(value) // "2081-05-12"
    console.log(dateObject) // { year: 2081, month: 5, day: 12 }
  }}
/>

Custom Calendar Props Interface

If you write a custom template via calendarComponent or renderCalendar, your component/function receives:

interface NepaliCalendarViewRenderProps {
  viewYear: number
  viewMonth: number
  calendarCells: (NepaliDateValue | null)[]
  isDisabled: (date: NepaliDateValue) => boolean
  handleDayChange: (day: number) => void
  goToPreviousMonth: () => void
  goToNextMonth: () => void
  BS_MONTHS: string[]
  WEEK_DAYS: string[]
  toNepaliNumber: (num: number) => string
}

Utility Exports

import {
  adToBs,
  bsToAd,
  adStringToBs,
  bsStringToAd,
  formatBSDate,
  parseBSDate,
  isValidBSDate,
  getAvailableYears,
  getMonthDays,
  toNepaliNumber,
} from 'nepali-bs-calendar-react'

Styling & Theme Customization

Overriding CSS variables is the easiest way to customize the look and feel. Because popups render via React Portals outside your local component tree, define overrides globally (e.g. on :root or body).

Date Picker CSS Variables

VariableDefaultDescription
--ndp-width100%Main picker width.
--ndp-gap6pxGap between label, trigger, and error.
--ndp-label-font-size14pxLabel font size.
--ndp-label-font-weight500Label font weight.
--ndp-label-color#222Label color.
--ndp-trigger-min-height40pxTrigger button minimum height.
--ndp-trigger-border#d9d9d9Trigger border color.
--ndp-trigger-border-hover#4096ffTrigger hover/open border color.
--ndp-trigger-radius8pxTrigger border radius.
--ndp-trigger-bg#fffTrigger background.
--ndp-trigger-padding8px 12pxTrigger padding.
--ndp-trigger-focus-shadow0 0 0 2px rgba(5, 145, 255, 0.12)Focus shadow.
--ndp-trigger-disabled-bg#f5f5f5Disabled trigger background.
--ndp-trigger-disabled-colorrgba(0, 0, 0, 0.25)Disabled trigger text color.
--ndp-value-colorrgba(0, 0, 0, 0.88)Selected value text color.
--ndp-placeholder-colorrgba(0, 0, 0, 0.4)Placeholder color.
--ndp-error-color#ff4d4fError color.
--ndp-error-font-size13pxError font size.
--ndp-popover-min-width280pxMinimum popup width.

Calendar Panel CSS Variables

VariableDefaultDescription
--nc-border-color#e5e7ebCalendar border color.
--nc-border-radius12pxCalendar border radius.
--nc-bg#fffCalendar background.
--nc-shadow0 12px 32px rgba(15, 23, 42, 0.18)Calendar shadow.
--nc-padding14pxCalendar padding.
--nc-font-familysystem-ui, -apple-system...Calendar font family.
--nc-header-gap8pxHeader gap.
--nc-header-margin-bottom12pxHeader bottom margin.
--nc-title-font-size16pxCalendar title font size.
--nc-title-font-weight600Calendar title font weight.
--nc-title-color#111827Calendar title color.
--nc-nav-btn-size32pxPrevious/next button size.
--nc-nav-btn-border-color#e5e7ebPrevious/next button border color.
--nc-nav-btn-radius8pxPrevious/next button radius.
--nc-nav-btn-bg#fffPrevious/next button background.
--nc-nav-btn-color#111827Previous/next button text color.
--nc-nav-btn-hover-bg#f9fafbPrevious/next hover background.
--nc-nav-btn-font-size22pxPrevious/next arrow font size.
--nc-controls-gap8pxGap between year, month, and day selects.
--nc-controls-margin-bottom12pxControls bottom margin.
--nc-select-height34pxSelect input height.
--nc-select-border-color#d1d5dbSelect input border color.
--nc-select-radius8pxSelect input border radius.
--nc-select-bg#fffSelect input background.
--nc-select-color#111827Select input text color.
--nc-select-padding0 8pxSelect input padding.
--nc-grid-gap4pxGap between date cells.
--nc-weekdays-margin-bottom6pxWeekday row bottom margin.
--nc-weekday-font-size12pxWeekday font size.
--nc-weekday-font-weight600Weekday font weight.
--nc-weekday-color#6b7280Weekday text color.
--nc-cell-min-height36pxDate cell minimum height.
--nc-cell-radius8pxDate cell border radius.
--nc-cell-bgtransparentDate cell background.
--nc-cell-color#111827Date cell text color.
--nc-cell-hover-bg#f3f4f6Date cell hover background.
--nc-cell-selected-bg#1677ffSelected date background.
--nc-cell-selected-color#fffSelected date text color.
--nc-cell-selected-hover-bg#1677ffSelected date hover background.
--nc-cell-disabled-color#bdbdbdDisabled date text color.
--nc-cell-disabled-bgtransparentDisabled date background.

Mobile Responsive Styling Variables

:root {
  --nc-mobile-padding: 12px;
  --nc-mobile-title-font-size: 15px;
  --nc-mobile-nav-btn-size: 30px;
  --nc-mobile-cell-min-height: 34px;
  --nc-mobile-cell-font-size: 13px;
 
  --nc-small-padding: 10px;
  --nc-small-title-font-size: 14px;
  --nc-small-cell-min-height: 32px;
  --nc-small-cell-font-size: 12px;
 
  --nc-tiny-padding: 8px;
  --nc-tiny-cell-min-height: 30px;
  --nc-tiny-cell-font-size: 11px;
}