Custom Event Sort
Usage
theme="ios" You can turn auto theming on and let it decide based on the platform.
Usage
themeVariant="light" You can turn auto dark mode on based on system settings.
Usage
locale={localeEn} Selecting the locale loads the localized settings and the translated UI text.
Custom Event Sort
When rendering events, the default logic determines the order:
- All-day events are placed at the top
- Non-all-day events follow, sorted by their start times
- Events with the same start time are ordered alphabetically by their title
The order property of the event data can be used to override the default ordering. The order property takes precedence over the default rules. If two events have the same order value, the default rules apply. For a more advanced order logic, the eventOrder option can be used which expects a function that compares two events and returns an order (-1 or 1).
Do you want to learn about the event ordering? Learn more about it in the documentation →
Demo

Code
View code on GitHub
import { Eventcalendar, setOptions } from '@mobiscroll/react';
import { useMemo } from 'react';
setOptions({
locale: ,
theme: ' ',
themeVariant: ' '
});
const now = new Date();
const day = now.getDay();
const monday = now.getDate() - day + (day == 0 ? -6 : 1);
function App() {
const myEvents = useMemo(
() => [
{
start: new Date(now.getFullYear(), now.getMonth(), monday),
title: 'Kate OFF (PROPOSED)',
color: '#e7b300',
allDay: true,
accepted: false,
order: 1,
},
{
start: new Date(now.getFullYear(), now.getMonth(), monday),
title: 'John OFF (APPROVED)',
color: '#00ca10',
allDay: true,
accepted: true,
order: 2,
},
{
start: new Date(now.getFullYear(), now.getMonth(), monday),
title: 'Mark OFF (PROPOSED)',
color: '#e7b300',
allDay: true,
accepted: false,
order: 1,
},
{
start: new Date(now.getFullYear(), now.getMonth(), monday),
title: 'Emma OFF (PROPOSED)',
color: '#e7b300',
allDay: true,
accepted: false,
order: 1,
},
{
start: new Date(now.getFullYear(), now.getMonth(), monday + 1),
title: 'Mark OFF (APPROVED)',
color: '#00ca10',
allDay: true,
accepted: true,
order: 2,
},
{
start: new Date(now.getFullYear(), now.getMonth(), monday + 1),
title: 'Carol OFF (PROPOSED)',
color: '#e7b300',
allDay: true,
accepted: false,
order: 1,
},
{
start: new Date(now.getFullYear(), now.getMonth(), monday + 2),
title: 'Luke OFF (PROPOSED)',
color: '#e7b300',
allDay: true,
accepted: false,
order: 1,
},
{
start: new Date(now.getFullYear(), now.getMonth(), monday + 2),
title: 'Carol OFF (APPROVED)',
color: '#00ca10',
allDay: true,
accepted: true,
order: 2,
},
{
start: new Date(now.getFullYear(), now.getMonth(), monday + 2),
title: 'Kate OFF (APPROVED)',
color: '#00ca10',
allDay: true,
accepted: true,
order: 2,
},
{
start: new Date(now.getFullYear(), now.getMonth(), monday + 2),
title: 'Dean OFF (PROPOSED)',
color: '#e7b300',
allDay: true,
accepted: false,
order: 1,
},
{
start: new Date(now.getFullYear(), now.getMonth(), monday + 2),
title: 'Emma OFF (APPROVED)',
color: '#00ca10',
allDay: true,
accepted: true,
order: 2,
},
{
start: new Date(now.getFullYear(), now.getMonth(), monday + 2),
title: 'Jason OFF (APPROVED)',
color: '#00ca10',
allDay: true,
accepted: true,
order: 2,
},
{
start: new Date(now.getFullYear(), now.getMonth(), monday + 3),
title: 'Jason OFF (APPROVED)',
color: '#00ca10',
allDay: true,
accepted: true,
order: 2,
},
{
start: new Date(now.getFullYear(), now.getMonth(), monday + 4),
title: 'Ryan OFF (PROPOSED)',
color: '#e7b300',
allDay: true,
accepted: false,
order: 1,
},
{
start: new Date(now.getFullYear(), now.getMonth(), monday + 4),
title: 'John OFF (APPROVED)',
color: '#00ca10',
allDay: true,
accepted: true,
order: 2,
},
{
start: new Date(now.getFullYear(), now.getMonth(), monday + 4),
title: 'Dean OFF (PROPOSED)',
color: '#e7b300',
allDay: true,
accepted: false,
order: 1,
},
],
[],
);
const myView = useMemo(() => ({ agenda: { type: 'week' } }), []);
return <Eventcalendar view={myView} data={myEvents} />;
}
export default App;
import { Eventcalendar, MbscCalendarEvent, MbscEventcalendarView, setOptions } from '@mobiscroll/react';
import { useMemo } from 'react';
setOptions({
locale: ,
theme: ' ',
themeVariant: ' '
});
const now = new Date();
const day = now.getDay();
const monday = now.getDate() - day + (day == 0 ? -6 : 1);
function App() {
const myEvents = useMemo<MbscCalendarEvent[]>(
() => [
{
start: new Date(now.getFullYear(), now.getMonth(), monday),
title: 'Kate OFF (PROPOSED)',
color: '#e7b300',
allDay: true,
accepted: false,
order: 1,
},
{
start: new Date(now.getFullYear(), now.getMonth(), monday),
title: 'John OFF (APPROVED)',
color: '#00ca10',
allDay: true,
accepted: true,
order: 2,
},
{
start: new Date(now.getFullYear(), now.getMonth(), monday),
title: 'Mark OFF (PROPOSED)',
color: '#e7b300',
allDay: true,
accepted: false,
order: 1,
},
{
start: new Date(now.getFullYear(), now.getMonth(), monday),
title: 'Emma OFF (PROPOSED)',
color: '#e7b300',
allDay: true,
accepted: false,
order: 1,
},
{
start: new Date(now.getFullYear(), now.getMonth(), monday + 1),
title: 'Mark OFF (APPROVED)',
color: '#00ca10',
allDay: true,
accepted: true,
order: 2,
},
{
start: new Date(now.getFullYear(), now.getMonth(), monday + 1),
title: 'Carol OFF (PROPOSED)',
color: '#e7b300',
allDay: true,
accepted: false,
order: 1,
},
{
start: new Date(now.getFullYear(), now.getMonth(), monday + 2),
title: 'Luke OFF (PROPOSED)',
color: '#e7b300',
allDay: true,
accepted: false,
order: 1,
},
{
start: new Date(now.getFullYear(), now.getMonth(), monday + 2),
title: 'Carol OFF (APPROVED)',
color: '#00ca10',
allDay: true,
accepted: true,
order: 2,
},
{
start: new Date(now.getFullYear(), now.getMonth(), monday + 2),
title: 'Kate OFF (APPROVED)',
color: '#00ca10',
allDay: true,
accepted: true,
order: 2,
},
{
start: new Date(now.getFullYear(), now.getMonth(), monday + 2),
title: 'Dean OFF (PROPOSED)',
color: '#e7b300',
allDay: true,
accepted: false,
order: 1,
},
{
start: new Date(now.getFullYear(), now.getMonth(), monday + 2),
title: 'Emma OFF (APPROVED)',
color: '#00ca10',
allDay: true,
accepted: true,
order: 2,
},
{
start: new Date(now.getFullYear(), now.getMonth(), monday + 2),
title: 'Jason OFF (APPROVED)',
color: '#00ca10',
allDay: true,
accepted: true,
order: 2,
},
{
start: new Date(now.getFullYear(), now.getMonth(), monday + 3),
title: 'Jason OFF (APPROVED)',
color: '#00ca10',
allDay: true,
accepted: true,
order: 2,
},
{
start: new Date(now.getFullYear(), now.getMonth(), monday + 4),
title: 'Ryan OFF (PROPOSED)',
color: '#e7b300',
allDay: true,
accepted: false,
order: 1,
},
{
start: new Date(now.getFullYear(), now.getMonth(), monday + 4),
title: 'John OFF (APPROVED)',
color: '#00ca10',
allDay: true,
accepted: true,
order: 2,
},
{
start: new Date(now.getFullYear(), now.getMonth(), monday + 4),
title: 'Dean OFF (PROPOSED)',
color: '#e7b300',
allDay: true,
accepted: false,
order: 1,
},
],
[],
);
const myView = useMemo<MbscEventcalendarView>(() => ({ agenda: { type: 'week' } }), []);
return <Eventcalendar view={myView} data={myEvents} />;
}
export default App;