You can implement a calendar in React Native using the popular react-native-calendars library by Wix. It provides a simple and customizable calendar UI out of the box.
npm install react-native-calendars
<Calendar
onDayPress={day => {
setSelectedDate(day.dateString);
}}
markedDates={{
[selectedDate]: {
selected: true,
marked: true,
selectedColor: 'blue',
},
}}
/>
import React, { useState } from 'react';
import { View, Text, StyleSheet } from 'react-native';
import { Calendar } from 'react-native-calendars';
const MyCalendar = () => {
const [selectedDate, setSelectedDate] = useState('');
return (
{
setSelectedDate(day.dateString);
}}
markedDates={{
[selectedDate]: {
selected: true,
marked: true,
selectedColor: 'blue',
},
}}
/>
{selectedDate ? (
Selected Date: {selectedDate}
) : (
No date selected
)}
);
};
const styles = StyleSheet.create({
container: {
marginTop: 50,
padding: 16,
},
dateText: {
marginTop: 20,
fontSize: 18,
textAlign: 'center',
},
});
export default MyCalendar;
Work with our skilled React Native developers to accelerate your project and boost its performance.
Hire React Native Developers