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.
npm install nepali-calender-sarojimport { 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.
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.
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
| Prop | Type | Default | Description |
|---|---|---|---|
value | BsDate | null | — | Controlled selected date. Pass null to clear. |
defaultValue | BsDate | — | Uncontrolled default selection. |
onChange | (bs, ad) => void | — | Called on day click or clear. |
showNepali | boolean | true | Use Nepali (Devanagari) script for labels and digits. |
showSelectedBar | boolean | true | Show the selected-date strip below the grid. |
mode | "dark" | "light" | "dark" | Colour theme for the component. |
className | string | — | Extra CSS class on the root element. |
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.
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
| Prop | Type | Default | Description |
|---|---|---|---|
value | BsDate | null | — | Controlled selected date. Pass null to clear. |
onChange | (bs, ad) => void | — | Called when a date is picked or cleared. |
placeholder | string | "मिति छान्नुहोस्" | Placeholder text shown when nothing is selected. |
showNepali | boolean | true | Use Nepali script for labels and digits. |
mode | "dark" | "light" | "light" | Colour theme for the component. |
className | string | — | Extra CSS class on the root element. |
Both components accept a mode prop. Wire it to your app's theme state for seamless runtime theme switching.
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)} />
</>
);
}Set showNepali={false} to use English month names and Arabic numerals instead of Devanagari script.
<NepaliCalendar showNepali={false} onChange={(bs, ad) => console.log(bs, ad)} />
<NepaliDatePicker showNepali={false} placeholder="Select date" onChange={(bs, ad) => console.log(bs, ad)} />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>
</>
);
}<NepaliCalendar
defaultValue={{ year: 2080, month: 6, day: 15 }}
onChange={(bs) => console.log(bs)}
/><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)}`);
}}
/><NepaliCalendar showSelectedBar={false} onChange={(bs) => console.log(bs)} />Utility Functions
Standalone helpers for date conversion and formatting — usable anywhere.
Convert a Gregorian Date object to a BS date object. Returns null if the date falls outside the supported BS 2000–2090 range.
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)Convert a BS date (year, month, day as numbers) to a Gregorian Date. Returns null for invalid values or years outside the supported range.
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)Convert Arabic numerals (as a number or string) to Nepali Devanagari digit characters.
import { toNepaliNumber } from "nepali-calender-saroj";
toNepaliNumber(2082); // "२०८२"
toNepaliNumber("15"); // "१५"
toNepaliNumber(1234567); // "१२३४५६७"Format a BS date as a human-readable string. Pass true (default) for Devanagari output or false for English.
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)Format a Gregorian Date as a short English string.
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.
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.
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 Year | Gregorian Equivalent | Notes |
|---|---|---|
| BS 2000 | ~1943 AD | Start of supported range |
| BS 2082 | ~2025 AD | Current year (verified anchor date) |
| BS 2090 | ~2033 AD | End of supported range |
Data sourced from official Nepali Patro records. Anchor: BS 2082 Baisakh 1 = 2025-04-14.
Changelog
Version history and release notes.
- Added
modeprop ("dark" | "light") to both components - Exported
CalendarModetype - Dark mode remains the default — no breaking changes
- Light mode uses a warm stone palette with amber accents
- Rewrote all components in TypeScript with full type exports
- Fixed
start_day_of_yeargrid offset calculation (isoWeekday → Sun-start index) - Added
formatBsDate,formatAdDateutilities - Added
NEPALI_MONTHS_EN,EN_WEEKDAYS_SHORTconstants - Added bounds validation to
bsToAd - Styles injected once via
injectStyles()— safe for SSR/Next.js - Keyboard accessibility (Enter/Space) on day cells
NepaliDatePickercloses on outside click