1.0.0 โ€ข Published 23 days ago

@symbiot.dev/react-native-swipeday v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
23 days ago

react-native-swipeday is a horizontally swipeable React Native component that displays individual days. It enables smooth left and right swiping to navigate between days, making it ideal for daily planners, calendars, habit trackers, and similar apps. Unlike a timeline, each slide focuses on a single full day, giving you complete control over the day's content. The component is built with full support for iOS, Android, Web, Expo, and Expo Go, making it highly versatile and easy to integrate across platforms.


๐Ÿ“ฑ Demo


โœจ Key Features

๐Ÿ“… Swipeable Day View โ€“ Navigate horizontally through days with optional snapping.
๐Ÿ‘ฅ Group-Based Layout โ€“ Organize your day view by teams, rooms, users, etc.
๐ŸŽจ Custom Renderers โ€“ Inject your own headers, day content, or group layout via render props.
๐Ÿ“ฑ Cross-Platform Support โ€“ Works seamlessly across:

  • iOS & Android
  • Web via React Native Web
  • Expo & Expo Go

๐Ÿง  Minimal & Extensible โ€“ Lightweight core with deep customization hooks.
๐Ÿš€ Performance Friendly โ€“ Virtualized scrolling and render control for optimal responsiveness.


๐Ÿง  Ideal For

  • ๐Ÿ‘ฅ Employee shift planners
  • ๐Ÿ›Ž๏ธ Booking views by room, therapist, stylist, etc.
  • ๐Ÿ“† Grouped daily timelines
  • ๐Ÿง‘โ€๐Ÿซ Class schedules split by instructor or location
  • ๐Ÿ“ฆ Delivery or service assignments by region
  • ๐Ÿ›  Field service or technician dispatch views
  • ๐Ÿงญ Any multi-entity day-based scheduling need

๐Ÿ“ฆ Installation

npm install @symbiot.dev/react-native-swipeday date-fns react-native-reanimated react-native-gesture-handler
# or
yarn add @symbiot.dev/react-native-swipeday date-fns react-native-reanimated react-native-gesture-handler

# for web support
npm i react-native-web
# or
yarn add react-native-web
import { SwipeDay } from '@symbiot.dev/react-native-swipeday';

// ... and voilร  ๐Ÿ’ซ
<SwipeDay />

๐ŸŽจ SwipeDayThemeProps โ€“ Theming & Appearance

You can customize the look and feel of SwipeDay using the theme prop. It supports both global styles and scheme-based overrides for 'light' and 'dark' modes.

๐Ÿงฉ Structure

The SwipeDayThemeProps type supports three layers:

  1. Global Styling (applies to all schemes unless overridden)
  2. Per-scheme Overrides โ€“ Use light and dark keys to define specific values
  3. Theme Scheme Selector โ€“ Control active theme using scheme
type SwipeDayThemeProps = SwipeDayStyle & {
  scheme?: 'light' | 'dark';
  light?: SwipeDayStyle;
  dark?: SwipeDayStyle;
};

๐Ÿงฑ Available Styling Props

Prop NameDescriptioniOSAndroidWebDefault Value
backgroundColorMain background color of the grid viewโœ…โœ…โœ…light: #FFFFFF, dark: #000000
dayHeaderBackgroundColorBackground for the day-of-week header barโœ…โœ…โœ…light: #FFFFFF, dark: #000000
dayHeaderTextColorText color for day-of-week labelsโœ…โœ…โœ…light: #000000, dark: #FFFFFF
groupHeaderBackgroundColorBackground for the group header barโœ…โœ…โœ…light: #FFFFFF, dark: #000000
groupHeaderTextColorText color for group labelsโœ…โœ…โœ…light: #000000, dark: #FFFFFF
verticalLineColorColor of vertical grid linesโœ…โœ…โœ…light: #F1F1F1, dark: #303030
horizontalLineColorColor of horizontal grid linesโœ…โœ…โœ…light: #F1F1F1, dark: #303030
<SwipeDay
  //...
  theme={{
    backgroundColor: '#f0f0f0', // for light and dark mode
  }}
/>

// ----

<SwipeDay
  //...
  theme={{
    backgroundColor: '#f0f0f0', // only applies to light mode
    dark: {
      backgroundColor: '#020202',
    },
  }}
/>

๐Ÿ“ SwipeDayDimensionsProps โ€“ Layout & Dimensions

Control the physical dimensions of key areas inside the SwipeDay. All values are in pixels and optional โ€” sensible defaults are provided.

๐Ÿงฑ Available Dimension Props

Prop NameDescriptioniOSAndroidWebDefault Value
widthSwipeDay widthโœ…โœ…โœ…system
dayHeaderHeightHeight of the day header (weekday labels)โœ…โœ…โœ…50
groupHeaderHeightHeight of the group header (group labels)โœ…โœ…โœ…30
horizontalLineSizeHeight of horizontal divider linesโœ…โœ…โœ…0.5
<SwipeDay
  //...
  width={300}
/>;

๐Ÿ“… SwipeDayDatetimeProps โ€“ Date & Time Configuration

Set the visible time range, number of days, start date, and other calendar-related behaviors.
These props give you precise control over how the SwipeDay renders days and time slots.

๐Ÿงฑ Available Datetime Props

Prop NameDescriptioniOSAndroidWebDefault Value
startDateThe starting datetime for the initial calendar stateโœ…โœ…โœ…new Date()
weekStartsOnDay the week starts on (0=Sun, 1=Mon, etc.)โœ…โœ…โœ…0 (Sunday)
hiddenDaysDays of the week to hide (e.g., [0, 6] to hide Sun & Sat)โœ…โœ…โœ…[]
numberOfDaysNumber of days to render in the viewโœ…โœ…โœ…1
minDateEarliest date to allow navigationโœ…โœ…โœ…โ€”
maxDateLatest date to allow navigationโœ…โœ…โœ…โ€”
<SwipeDay
  //...
  weekStartsOn={1} // starts on Monday
  numberOfDays={3}
  hiddenDays={[0, 6]} // exclude weekends (Sun,Sut)
/>;

๐ŸŽฎ SwipeDayControllerProps โ€“ Interaction & Display Toggles

Control user interaction features like swiping, snapping, and visibility of UI components like the headers.

๐Ÿงฑ Available Controller Props

Prop NameDescriptioniOSAndroidWebDefault Value
swipeableEnable swiping between days or weeksโœ…โœ…โœ…false
snappableSnap scroll/drag to the nearest date(or group in groupable mode)โœ…โœ…โœ…false
debounceableDelays date change handler to avoid rapid successive triggers.โœ…โœ…โœ…false
rtlEnable right-to-left layout (for RTL languages)โœ…โœ…โœ…false
isDayHeaderVisibleToggle visibility of the top day-of-week headerโœ…โœ…โœ…true
isGroupHeaderVisibleToggle visibility of the top group headerโœ…โœ…โœ…true
<SwipeDay
  //...
  swipeable // swipe actions turned on
  scrollable // user can scroll
  snappable // date/group snapping enabled
/>

๐Ÿ”ง SwipeDayScrollProps โ€“ Scroll and Refresh Control

These types control the scroll and refresh behavior for day-based components, allowing flexible configuration either globally, per group, or per specific date.

๐Ÿ” SwipeDayScrollProp

Defines the scroll or refresh state and can be one of the following:

  • boolean โ€” enable or disable scrolling/refreshing globally.
  • Record<string, boolean> โ€” keyed by group IDs to enable or disable per group.
  • Array<{ groupId: string; date: string; value: boolean }> โ€” fine-grained control by group and date.

๐Ÿงฑ SwipeDayScrollProps

Props that manage scroll and refresh capabilities:

Prop NameDescriptioniOSAndroidWebDefault Value
scrollableControls if day scrolling is enabled, with flexible options.โœ…โœ…โœ…false
refreshableControls if pull-to-refresh is enabled, with flexible options.โœ…โœ…โž–false
refreshingIndicates the refreshing state, useful for UI feedback.โœ…โœ…โž–false

๐Ÿ“ฆ Example Usage

<SwipeDay
  //...
  scrollable // enable scroll for all days
/>

๐Ÿ“ฆ SwipeGayGroupProps โ€“ Groups

Configure how groups are handled in the SwipeGay component.

๐Ÿงฑ Available Props

Prop NameDescriptioniOSAndroidWebDefault Value
groupableControls days splitting by groupsโœ…โœ…โœ…false
numberOfGroupsOptional number of groups to displayโœ…โœ…โœ…groups size
groupsOptional array of group objects (SwipeGayGroup[])โœ…โœ…โœ…[]

Example Usage

const groups = [
  { id: 1, name: 'Group A' },
  { id: 2, name: 'Group B' },
];

<SwipeGayComponent
  //...
  numberOfGroups={2}
  groups={groups}
/>

โฑ SwipeDayFormatterProps โ€“ Text Formatting

Customize how dates and times appear within the SwipeDay component using format strings (e.g., dd, HH:mm, EEE).
These follow date-fns formatting syntax.

๐Ÿงฑ Available Formatter Props

Prop NameDescriptioniOSAndroidWebDefault Value
dayHeaderTextFormatFormat for the day header labels (e.g., Mon, Apr 20)โœ…โœ…โœ…EEEEEE dd
localeLocale object from date-fns for internationalized formattingโœ…โœ…โœ…en
import { zhCN } from 'date-fns/locale/zh-CN';

<SwipeDay
  //...
  locale={zhCN} // Chinese localization
/>;

๐Ÿงญ SwipeDayActionsProps โ€“ User Interaction Callbacks

Callbacks to handle user interactions within a swipeable day grid, such as taps, long presses, header presses, and data refreshes.

๐Ÿงฑ Available Action Callbacks

Prop NameDescriptioniOSAndroidWeb
onLoadCalled once the component is initialized and readyโœ…โœ…โœ…
onChangeDateTriggered when the selected date changesโœ…โœ…โœ…
onRefreshCalled when the grid requests a manual refresh of dataโœ…โœ…โž–
onGroupHeaderPressTriggered when a group header is tappedโœ…โœ…โœ…
onDayHeaderPressCalled when the day header is tappedโœ…โœ…โœ…
onDayPressTriggered when a day cell is tappedโœ…โœ…โœ…
onDayLongPressTriggered on a long press of a day cellโœ…โœ…โœ…
import { useState } from 'react';

//...
const [selectedDate, setSelectedDate] = useState(new Date());

<SwipeDay
  //...
  onChangeDate={setSelectedDate} // Update selected date on swipe or tap
  onRefresh={({ date }) => console.log('Refreshing data for:', date)}
  onGroupHeaderPress={({ groupId }) => console.log('Group pressed:', groupId)}
  onDayLongPress={({ date }) => console.log('Long pressed:', date)}
/>


๐Ÿ”ง SwipeDayRef โ€“ Imperative Control API

Control and interact with the SwipeDay instance programmatically using a React ref.
Great for custom toolbars, buttons, or dynamic navigation.

๐Ÿงฑ Available Ref Methods

MethodDescriptionReturns
getPrevDate()Returns the previous valid date range (optionally ignoring minDate/maxDate)Date \| undefined
getNextDate()Returns the next valid date range (optionally ignoring minDate/maxDate)Date \| undefined
prevDate()Navigate to the previous available datevoid
nextDate()Navigate to the next available datevoid
back()Navigate backward through a specified number of days (numberOfDays)void
forward()Navigate forward through a specified number of days (numberOfDays)void
import { useRef } from 'react';
import { SwipeDay, SwipeDayRef } from '@symbiot.dev/react-native-swipeday';

const swipeDayRef = useRef<SwipeDayRef>(null);

<SwipeDay
  //...
  ref={swipeDayRef}
/>

//...
<Pressable onPress={() => swipeDayRef.current?.forward()}>{/*...*/}</Pressable>

๐ŸŒ Platform Support

  • โœ… iOS
  • โœ… Android
  • โœ… Web
  • โœ… Expo & Expo Go

๐Ÿ“ฆ Bundle Size

Lightweight and fast โ€” see actual size on Bundlephobia.


๐Ÿ’ฌ Contributing

Contributions welcome! Feel free to open issues, discussions, or suggestions.


๐ŸŒŸ Who's Using This?

Using react-native-swipeday in your app or product?
Feel free to share your project โ€” it might be featured in this section!

โœ‰๏ธ Open pull request, or reach out directly to get included.


๐Ÿš€ Got Ideas or Gaps to Fill?

Know of existing libraries or functionality that could be improved?
Have an idea for something completely new?

Symbiot is ready to take on the challenge โ€” feedback, feature requests, or collaboration ideas are always welcome!

๐Ÿง  Letโ€™s build better tools together. Start the conversation or contact via email.


๐Ÿงพ License

MIT โ€” Made with โค๏ธ by Symbiot