React Native Lite Calendar
A lightweight and customizable calendar component for React Native applications
with support for both English and Korean languages.
Screenshots
Features
- 📅 Simple and intuitive calendar interface
- 🎨 Highly customizable styles
- 🌏 Multi-language support (English & Korean)
- 📱 Cross-platform compatibility
- 🔍 Modal view support
- 🎯 Configurable date selection range with min/max dates
- ✨ Today highlighting
- 🎈 Special date marking
- 🎭 Custom themes with color schemes
Installation
# Using npm
npm install @choi12/react-native-lite-calendar
# Using yarn
yarn add @choi12/react-native-lite-calendar
Peer Dependencies
This package requires the following peer dependencies:
{
"react": ">=17.0.0",
"react-native": ">=0.65.0",
"dayjs": ">=1.11.0"
}
Types
type CalendarDay = Dayjs; // dayjs object
type MarkedDate = string; // 'YYYY-MM-DD' format
Usage
Basic Calendar
import React, { useState } from 'react';
import { Calendar } from '@choi12/react-native-lite-calendar';
import dayjs from 'dayjs';
const MyCalendar = () => {
const [selectedDate, setSelectedDate] = useState(dayjs());
return (
<Calendar
selectedDate={selectedDate}
onSelectDate={setSelectedDate}
/>
);
};
Calendar Modal
import React, { useState } from 'react';
import { CalendarModal } from '@choi12/react-native-lite-calendar';
import dayjs from 'dayjs';
const MyCalendarModal = () => {
const [isVisible, setIsVisible] = useState(false);
const [selectedDate, setSelectedDate] = useState(dayjs());
return (
<CalendarModal
isVisible={isVisible}
onClose={() => setIsVisible(false)}
selectedDate={selectedDate}
onSelectDate={setSelectedDate}
/>
);
};
Props
Calendar Props
Prop | Type | Required | Default | Description |
---|
selectedDate | CalendarDay | Yes | - | Currently selected date |
onSelectDate | (date: CalendarDay) => void | Yes | - | Callback when a date is selected |
minDate | CalendarDay | No | - | Minimum selectable date |
maxDate | CalendarDay | No | - | Maximum selectable date |
initialDate | CalendarDay | No | dayjs() | Initial selected date |
language | 'en' | 'ko' | No | 'en' | Calendar language |
styles | CalendarStyles | No | {} | Custom styles object |
colors | CalendarColors | No | {} | Custom colors object |
markedDates | string[] | No | [] | Array of dates to be marked (YYYY-MM-DD format) |
CalendarModal Props
Extends Calendar Props with additional properties:
Prop | Type | Required | Default | Description |
---|
isVisible | boolean | Yes | - | Controls modal visibility |
onClose | () => void | Yes | - | Callback when modal is closed |
title | string | No | - | Modal title |
overlayOpacity | number | No | 0.5 | Opacity of modal overlay |
Customization
Theme Colors
const colors = {
primaryColor: '#8CD5E1', // Primary theme color
backgroundColor: '#FFFFFF', // Background color
textColor: '#4A4A4A', // Text color
};
Component Styles
const styles = {
// Calendar container
containerStyle: {},
daysContainerStyle: {},
weekStyle: {},
// Day elements
dayContainerStyle: {},
dayTextStyle: {},
selectedDayStyle: {},
selectedDayTextStyle: {},
todayLabelStyle: {},
weekendDayTextStyle: {},
disabledDayTextStyle: {},
// Month selector
monthSelectorContainerStyle: {},
monthSelectorButtonStyle: {},
monthTextStyle: {},
arrowStyle: {},
disabledArrowStyle: {},
// Weekday header
weekdayHeaderContainerStyle: {},
weekdayTextStyle: {},
weekendHeaderTextStyle: {},
// Modal specific (for CalendarModal)
modalOverlayStyle: {},
modalContainerStyle: {},
modalTitleStyle: {},
};
Full Example with Customization
<Calendar
selectedDate={selectedDate}
onSelectDate={setSelectedDate}
language="en"
initialDate={dayjs('2024-01-15')}
minDate={dayjs().subtract(2, 'month')}
maxDate={dayjs().add(2, 'month')}
markedDates={['2025-01-07', '2025-01-08']}
colors={{
primaryColor: '#8CD5E1',
backgroundColor: '#FFFFFF',
textColor: '#4A4A4A',
}}
styles={{
containerStyle: { borderRadius: 12 },
dayTextStyle: { fontSize: 14 },
selectedDayStyle: { backgroundColor: '#8CD5E1' },
selectedDayTextStyle: { color: '#FFFFFF' },
}}
/>
License
MIT © choi12