UNPKG

react-native-taqweem

Version:

**A dual calendar component (Hijri + Gregorian) for React Native** β€” minimal, customizable, and theme-ready. Perfect for apps needing culturally-aware calendars, Islamic date pickers, or just modern UX flexibility.

194 lines (123 loc) β€’ 4.72 kB
# react-native-taqweem **A dual calendar component (Hijri + Gregorian) for React Native** β€” minimal and customizable. Perfect for apps needing culturally-aware calendars, Islamic date pickers, or just modern UX flexibility. ## πŸ•Œ What is β€œTaqweem”? The word Taqweem (ΨͺΩ‚ΩˆΩŠΩ…) is Arabic for β€œcalendar” or β€œsystem of timekeeping.” It refers to how dates are calculated and organized β€” whether by the moon (Hijri) or the sun (Gregorian). The name reflects the component's purpose: a culturally-aware dual calendar for modern apps. ## βœ… **Features** ### πŸ“† Calendar Modes - βœ… Supports both **Hijri** and **Gregorian** calendars - βœ… Swappable via `calendarMode` prop (`'hijri' | 'gregorian'`) --- ### πŸ—“ Date Display & Navigation - βœ… Displays correct **day grid for the month** - βœ… Handles **adjacent days** (padding from prev/next months) β€’ Controlled by `showAdjacentMonths` prop - βœ… Month & year **header** with centered title - βœ… `<` and `>` arrows to navigate months - βœ… Arrows auto-hide when min/max bounds are reached - βœ… Supports custom header via `renderHeader` prop --- ### πŸ“ Selection Logic - βœ… Allows selecting a single day - βœ… Toggles selection on repeat tap - βœ… Disables selection of future dates via `allowFutureDates` prop - βœ… Blocks navigation into future if `allowFutureDates === false` --- ### πŸ”’ Date Limits - βœ… Accepts `minDate` and `maxDate` as prop to restrict navigation & selection - βœ… Defaults to: β€’ `minDate`: `'1400-1'` (Hijri) or `'1900-1'` (Gregorian) β€’ `maxDate`: current date + 10 years --- ### πŸ“€ Event Emission - βœ… `onDateChange` prop to inform parent when a day is selected β€’ Provides: - `calendarDate`: in current `calendarMode` format - `gregorianDate`: always in `'YYYY-MM-DD'` - `hijriDate`: always in `'iYYYY-iM-iD'` - `momentObj`: full Moment object ## Installation Install **react-native-taqweem** with npm ```bash npm install react-native-taqweem ``` ## Usage/Examples ```typescript import React from 'react'; import {StyleSheet, View} from 'react-native'; import {Screen} from '@src/components'; import {DualCalendar} from 'react-native-taqweem'; const Home = () => { return ( <Screen> <View style={styles.main}> // Default calendar mode is gregorian <DualCalendar /> </View> </Screen> ); }; export default Home; ``` You can make the `calendarMode` as hijri to render Hijri calendar. ```typescript <DualCalendar calendarMode="hijri" /> ``` You can configure the theme using `calendarTheme` prop. ```typescript import {CalendarTheme, DualCalendar} from 'react-native-taqweem'; import {useTheme} from '@src/context/theme-context'; const getCalendarThemeStyles = (theme: 'light' | 'dark') => StyleSheet.create<CalendarTheme>({ calendarView: { backgroundColor: theme === 'light' ? '#f8f9fa' : '#212529', borderRadius: 16, }, ... // more configurable properties const Home = () => { const {theme, toggleTheme} = useTheme(); const calendarTheme = getCalendarThemeStyles(theme); return ( <Screen> <Button title="Toggle Theme" onPress={toggleTheme} /> <View style={styles.main}> <DualCalendar calendarTheme={calendarTheme} /> </View> </Screen> ); }; ``` You can customize calendar header ```typescript <View style={styles.main}> <DualCalendar renderHeader={props => <ModernCalendarHeader {...props} />} calendarMode={calendarMode} calendarTheme={calendarTheme} /> </View> ``` ## Screenshots ### Gregorian Calendar ![Gregorian Calendar](./assets/calendar_mode_gregorian.png) ### Hijri Calendar ![Hijri Calendar](./assets/calendar_mode_hijri.png) ### Switch between calendar modes ![Hijri Calendar](./assets/toggle-calendar-mode.gif) ### Configurable Theme and Look ![Theme support](./assets/calendar-theme.gif) ### Customize Header ![Custom Header](./assets/custom-header.jpg) ## Acknowledgements > Built with ❀️ using `moment-hijri` under the hood, supports localization, RTL, theming, and full date control. ## Authors - [@jawadvajeeh](https://www.github.com/jawadvajeeh) ## Contributing Thank you for your interest in contributing to **react-native-taqweem**! πŸ™Œ If you’d like to suggest a feature, report a bug, or collaborate in any way β€” please feel free to get in touch: πŸ“© **jawadvajeeh@gmail.com** Looking forward to hearing from you!