Overview

Everything you need to build Nepali-date-aware React applications.

📅

Inline Calendar

Drop a full BS month grid anywhere with a single import.

🔽

Date Picker

Trigger button + dropdown that closes on outside click.

🔁

AD ↔ BS Conversion

Accurate utilities for both conversion directions.

🇳🇵

Nepali Script

Devanagari labels and digits, togglable to English.

🌗

Dark & Light Mode

Built-in theme support via a single mode prop.

✅

Fully Typed

Complete TypeScript definitions for every export.

🎛

Controlled & Uncontrolled

Works like a standard React input element.

🪶

Zero Dependencies

Only React as a peer dependency — nothing else.

Quick Start

Up and running in under a minute.

bash
npm install nepali-calender-saroj
tsx
import { NepaliCalendar, NepaliDatePicker } from "nepali-calender-saroj";

export default function App() {
  return (
    <>
      {/* Inline calendar */}
      <NepaliCalendar onChange={(bs, ad) => console.log(bs, ad)} />

      {/* Dropdown date picker */}
      <NepaliDatePicker onChange={(bs, ad) => console.log(bs, ad)} />
    </>
  );
}

Components

Two plug-and-play components for every date-selection use case.

<NepaliCalendar />

An inline, full-month calendar grid rendered directly in your layout. Use it in forms, sidebars, dashboards, or anywhere you want the calendar always visible without a trigger button. Supports controlled mode, dark/light themes, Devanagari or English labels, and an optional selected-date strip.

mode:
showNepali:
showSelectedBar:
Live Preview — NepaliCalendar
‹२०८२ फाल्गुन›
आइत
सोम
मंगल
बुध
बिहि
शुक्र
शनि
१
२
३
४
५
६
७
८
९
१०
११
१२
१३
१४
१५
१६
१७
१८
१९
२०
२१
२२
२३
२४
२५
२६
२७
२८
२९
३०
मिति छानिएको छैन
tsx
import { NepaliCalendar } from "nepali-calender-saroj";
import { useState } from "react";
import type { BsDate, CalendarMode } from "nepali-calender-saroj";

function App() {
  const [date, setDate] = useState<BsDate | null>(null);

  return (
    <NepaliCalendar
      value={date}
      onChange={(bs, ad) => setDate(bs)}
      mode="dark"
      showNepali={true}
      showSelectedBar={true}
    />
  );
}

Props

PropTypeDefaultDescription
valueBsDate | null—Controlled selected date. Pass null to clear.
defaultValueBsDate—Uncontrolled default selection.
onChange(bs, ad) => void—Called on day click or clear.
showNepalibooleantrueUse Nepali (Devanagari) script for labels and digits.
showSelectedBarbooleantrueShow the selected-date strip below the grid.
mode"dark" | "light""dark"Colour theme for the component.
classNamestring—Extra CSS class on the root element.
<NepaliDatePicker />

A compact trigger button that opens a floating dropdown calendar. Perfect for forms where space is limited. Automatically closes when the user clicks outside the picker. The button displays the selected date or a configurable placeholder.

tsx
import { NepaliDatePicker } from "nepali-calender-saroj";

<NepaliDatePicker
  onChange={(bs, ad) => {
    if (bs) console.log(`BS: ${bs.year}/${bs.month}/${bs.day}`);
    if (ad) console.log(`AD: ${ad.toISOString().slice(0, 10)}`);
  }}
  placeholder="मिति छान्नुहोस्"
  mode="light"
  showNepali={true}
/>

Props

PropTypeDefaultDescription
valueBsDate | null—Controlled selected date. Pass null to clear.
onChange(bs, ad) => void—Called when a date is picked or cleared.
placeholderstring"मिति छान्नुहोस्"Placeholder text shown when nothing is selected.
showNepalibooleantrueUse Nepali script for labels and digits.
mode"dark" | "light""light"Colour theme for the component.
classNamestring—Extra CSS class on the root element.
Dark & Light Mode

Both components accept a mode prop. Wire it to your app's theme state for seamless runtime theme switching.

Side-by-side comparison
‹२०८२ फाल्गुन›
आइत
सोम
मंगल
बुध
बिहि
शुक्र
शनि
१
२
३
४
५
६
७
८
९
१०
११
१२
१३
१४
१५
१६
१७
१८
१९
२०
२१
२२
२३
२४
२५
२६
२७
२८
२९
३०
मिति छानिएको छैन
‹२०८२ फाल्गुन›
आइत
सोम
मंगल
बुध
बिहि
शुक्र
शनि
१
२
३
४
५
६
७
८
९
१०
११
१२
१३
१४
१५
१६
१७
१८
१९
२०
२१
२२
२३
२४
२५
२६
२७
२८
२९
३०
मिति छानिएको छैन
tsx
import { useState } from "react";
import { NepaliCalendar, type CalendarMode } from "nepali-calender-saroj";

function App() {
  const [mode, setMode] = useState<CalendarMode>("dark");

  return (
    <>
      <button onClick={() => setMode(m => m === "dark" ? "light" : "dark")}>
        Toggle theme
      </button>
      <NepaliCalendar mode={mode} onChange={(bs) => console.log(bs)} />
    </>
  );
}
English Labels

Set showNepali={false} to use English month names and Arabic numerals instead of Devanagari script.

English labels — showNepali={false}
‹2082 Falgun›
Sun
Mon
Tue
Wed
Thu
Fri
Sat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
No date selected
tsx
<NepaliCalendar   showNepali={false} onChange={(bs, ad) => console.log(bs, ad)} />
<NepaliDatePicker showNepali={false} placeholder="Select date" onChange={(bs, ad) => console.log(bs, ad)} />
Controlled Mode
tsx
import { useState } from "react";
import { NepaliCalendar, type BsDate } from "nepali-calender-saroj";

function MyForm() {
  const [date, setDate] = useState<BsDate | null>(null);

  return (
    <>
      <NepaliCalendar
        value={date}
        onChange={(bs) => setDate(bs)}
      />
      <p>Selected: {date ? `${date.year}/${date.month}/${date.day}` : "none"}</p>
      <button onClick={() => setDate(null)}>Clear</button>
    </>
  );
}
Start on a Specific Date
tsx
<NepaliCalendar
  defaultValue={{ year: 2080, month: 6, day: 15 }}
  onChange={(bs) => console.log(bs)}
/>
Get Both BS and AD Dates
tsx
<NepaliCalendar
  onChange={(bs, ad) => {
    if (bs) console.log(`BS: ${bs.year}/${bs.month}/${bs.day}`);
    if (ad) console.log(`AD: ${ad.toISOString().slice(0, 10)}`);
  }}
/>
Hide Selected-date Strip
tsx
<NepaliCalendar showSelectedBar={false} onChange={(bs) => console.log(bs)} />

Utility Functions

Standalone helpers for date conversion and formatting — usable anywhere.

adToBs(adDate)

Convert a Gregorian Date object to a BS date object. Returns null if the date falls outside the supported BS 2000–2090 range.

AD date (YYYY-MM-DD)
→{ year: 2081, month: ~4, day: 14 } (approximate — use real adToBs())
ts
import { adToBs } from "nepali-calender-saroj";

adToBs(new Date("2025-04-14"));
// → { year: 2082, month: 1, day: 1 }

adToBs(new Date());
// → { year: 2082, month: 11, day: 25 }  (today's BS date)

adToBs(new Date("1943-01-01"));
// → { year: 1999, month: 9, day: 17 }

adToBs(new Date("2035-01-01"));
// → null  (outside supported range)
bsToAd(year, month, day)

Convert a BS date (year, month, day as numbers) to a Gregorian Date. Returns null for invalid values or years outside the supported range.

BS Year
Month (1–12)
Day (1–32)
→AD ≈ 2026-01-01 (approximate — use real bsToAd())
ts
import { bsToAd } from "nepali-calender-saroj";

bsToAd(2082, 1, 1);
// → Date("2025-04-14")

bsToAd(2080, 12, 30);
// → Date("2024-04-12")

bsToAd(2099, 1, 1);
// → null  (outside supported range)
toNepaliNumber(num)

Convert Arabic numerals (as a number or string) to Nepali Devanagari digit characters.

Input number
→"२०८२"
ts
import { toNepaliNumber } from "nepali-calender-saroj";

toNepaliNumber(2082);    // "२०८२"
toNepaliNumber("15");    // "१५"
toNepaliNumber(1234567); // "१२३४५६७"
formatBsDate(year, month, day, nepali?)

Format a BS date as a human-readable string. Pass true (default) for Devanagari output or false for English.

Output comparison
NP →२०८२ बैशाख १५
EN →2082 Baisakh 15
ts
import { formatBsDate } from "nepali-calender-saroj";

formatBsDate(2082, 1, 15, true);   // "२०८२ बैशाख १५"
formatBsDate(2082, 1, 15, false);  // "2082 Baisakh 15"
formatBsDate(2082, 4, 1);          // "२०८२ श्रावण १"  (nepali=true by default)
formatAdDate(date)

Format a Gregorian Date as a short English string.

→Apr 14, 2025
ts
import { formatAdDate } from "nepali-calender-saroj";

formatAdDate(new Date("2025-04-14"));  // "Apr 14, 2025"
formatAdDate(new Date());              // "Mar 12, 2026"  (today)

Constants

Pre-built arrays for month names, weekdays, and digit characters.

NEPALI_MONTHS
बैशाखजेठअसारश्रावणभाद्रआश्विनकार्तिकमंसिरपुषमाघफाल्गुनचैत्र
NEPALI_MONTHS_EN
BaisakhJesthaAshadhShrawanBhadraAshwinKartikMangsirPoushMaghFalgunChaitra
NEPALI_WEEKDAYS (short)
आइतसोममंगलबुधबिहिशुक्रशनि
EN_WEEKDAYS_SHORT
SunMonTueWedThuFriSat
NEPALI_DIGITS
० (0)१ (1)२ (2)३ (3)४ (4)५ (5)६ (6)७ (7)८ (8)९ (9)
ts
import {
  NEPALI_MONTHS,          // ["बैशाख", "जेठ", ...]
  NEPALI_MONTHS_EN,       // ["Baisakh", "Jestha", ...]
  NEPALI_WEEKDAYS,        // ["आइतबार", "सोमबार", ...]
  NEPALI_WEEKDAYS_SHORT,  // ["आइत", "सोम", ...]
  EN_WEEKDAYS_SHORT,      // ["Sun", "Mon", ...]
  NEPALI_DIGITS,          // ["०", "१", ...]
} from "nepali-calender-saroj";

TypeScript Types

All exported types for strong type safety across your codebase.

interfaceBsDate
year: number // e.g. 2082
month: number // 1–12
day: number // 1–32
typeCalendarMode
"dark" | "light"
interfaceNepaliCalendarProps
value?: BsDate | null
defaultValue?: BsDate
onChange?: (bs, ad) => void
showNepali?: boolean
showSelectedBar?: boolean
mode?: CalendarMode
className?: string
interfaceNepaliDatePickerProps
value?: BsDate | null
onChange?: (bs, ad) => void
placeholder?: string
showNepali?: boolean
mode?: CalendarMode
className?: string
ts
import type {
  BsDate,               // { year, month, day }
  BsDetailedDate,       // full formatted date object
  CalendarMode,         // "dark" | "light"
  CalendarYear,         // single year entry from calendarData.json
  CalendarData,         // { years: CalendarYear[] }
  NepaliCalendarProps,  // props for <NepaliCalendar />
  NepaliDatePickerProps // props for <NepaliDatePicker />
} from "nepali-calender-saroj";

Calendar Data Range

91 years of verified Bikram Sambat calendar data.

BS YearGregorian EquivalentNotes
BS 2000~1943 ADStart of supported range
BS 2082~2025 ADCurrent year (verified anchor date)
BS 2090~2033 ADEnd of supported range

Data sourced from official Nepali Patro records. Anchor: BS 2082 Baisakh 1 = 2025-04-14.

Changelog

Version history and release notes.

v5.2.1 — Current
  • Added mode prop ("dark" | "light") to both components
  • Exported CalendarMode type
  • Dark mode remains the default — no breaking changes
  • Light mode uses a warm stone palette with amber accents
v5.1.1
  • Rewrote all components in TypeScript with full type exports
  • Fixed start_day_of_year grid offset calculation (isoWeekday → Sun-start index)
  • Added formatBsDate, formatAdDate utilities
  • Added NEPALI_MONTHS_EN, EN_WEEKDAYS_SHORT constants
  • Added bounds validation to bsToAd
  • Styles injected once via injectStyles() — safe for SSR/Next.js
  • Keyboard accessibility (Enter/Space) on day cells
  • NepaliDatePicker closes on outside click