Basic

By default the calendar starts from Sun which is represented 0 index. You can provide the index for any other day that you want as start of the week.

  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • Su
PropType
value (required)Date
onChange (required)(value: Date) => void
import React, { useCallback, useState } from 'react';
import { Calendar } from '@natscale/react-calendar';
import '@natscale/react-calendar/dist/main.css';
export function App() {
const [value, setValue] = useState(new Date());
const onChange = useCallback(
(val) => {
setValue(val);
},
[setValue],
);
return <Calendar value={value} onChange={onChange} />;
}

Start Day Of Week

By default the calendar starts from Sun which is represented 0 index. You can provide the index for any other day that you want as start of the week.

  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • Su
PropTypeDefaultEnum
startOfWeeknumber00 , 1 , 2 , 3 , 4 , 5 , 6
import React, { useCallback, useState } from 'react';
import { Calendar } from '@natscale/react-calendar';
import '@natscale/react-calendar/dist/main.css';
export function App() {
const [value, setValue] = useState(new Date());
const onChange = useCallback(
(val) => {
setValue(val);
},
[setValue],
);
return <Calendar startOfWeek={1} value={value} onChange={onChange} />;
}

Weekend

By default the calendar starts from Sun which is represented 0 index. You can provide the index for any other day that you want as start of the week.

  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • Su
PropTypeDefaultEnum
weekendsArray<number>[0,6]0 , 1 , 2 , 3 , 4 , 5 , 6
import React, { useCallback, useState } from 'react';
import { Calendar } from '@natscale/react-calendar';
import '@natscale/react-calendar/dist/main.css';
export function App() {
const [value, setValue] = useState(new Date());
const onChange = useCallback(
(val) => {
setValue(val);
},
[setValue],
);
return <Calendar weekends={[0, 6]} value={value} onChange={onChange} />;
}

Change Labels

The calendar uses english labels for months and weeks by default. But you can change it using the props provided.

  • Lu
  • Ma
  • Me
  • Je
  • Ve
  • Sa
  • Di
PropType
weekDaysLabelRecord<0 ... 6, string>
monthsLabelRecord<0 ... 11, string>
import React, { useCallback, useState } from 'react';
import { Calendar } from '@natscale/react-calendar';
import '@natscale/react-calendar/dist/main.css';
const monthsLabel = {
0: 'janvier',
1: 'février',
2: 'mars',
3: 'avril',
4: 'mai',
5: 'juin',
6: 'juillet',
7: 'août',
8: 'septembre',
9: 'octobre',
10: 'novembre',
11: 'décembre',
};
const weekDaysLabel = {
0: 'Di',
1: 'Lu',
2: 'Ma',
3: 'Me',
4: 'Je',
5: 'Ve',
6: 'Sa',
};
export default function App() {
const [value, setValue] = useState(new Date());
const onChange = useCallback(
(val) => {
setValue(val);
},
[setValue],
);
return <Calendar weekDaysLabel={weekDaysLabel} monthsLabel={monthsLabel} value={value} onChange={onChange} />;
}

Select Multiple Dates

Enable multi selection.

  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • Su
PropTypeDefault
isMultiSelectorbooleanfalse
value (required)Array<Date>
onChange (required)(value: Array<Date>) => void
import React, { useCallback, useState } from 'react';
import { Calendar } from '@natscale/react-calendar';
import '@natscale/react-calendar/dist/main.css';
export function App() {
const [value, setValue] = useState([]);
const onChange = useCallback(
(val) => {
setValue(val);
},
[setValue],
);
return <Calendar isMultiSelector value={value} onChange={onChange} />;
}

Select Date Range

Select a date range.

  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • Su
PropTypeDefault
isRangeSelectorbooleanfalse
value (required)[Date, Date]
onChange (required)(value: [Date, Date]) => void
import React, { useCallback, useState } from 'react';
import { Calendar } from '@natscale/react-calendar';
import '@natscale/react-calendar/dist/main.css';
export function App() {
const [value, setValue] = useState([]);
const onChange = useCallback(
(val) => {
setValue(val);
},
[setValue],
);
return <Calendar isRangeSelector value={value} onChange={onChange} />;
}

Fixed Date Range

Only works if calendar is a range selector
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • Su
PropTypeDefault
fixedRangenumberundefined
value (required)[Date, Date]
onChange (required)(value: [Date, Date]) => void
import React, { useCallback, useState } from 'react';
import { Calendar } from '@natscale/react-calendar';
import '@natscale/react-calendar/dist/main.css';
export function App() {
const [value, setValue] = useState([new Date(2022, 6, 1), new Date(2022, 6, 6)]);
const onChange = useCallback(
(val) => {
setValue(val);
},
[setValue],
);
return <Calendar fixedRange={5} isRangeSelector value={value} onChange={onChange} />;
}

Date Range With No Padding

Only works if calendar is a range selector
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • Su
PropTypeDefault
noPadRangeCellbooleanfalse
import React, { useCallback, useState } from 'react';
import { Calendar } from '@natscale/react-calendar';
import '@natscale/react-calendar/dist/main.css';
export function App() {
const [value, setValue] = useState([]);
const onChange = useCallback(
(val) => {
setValue(val);
},
[setValue],
);
return <Calendar noPadRangeCell isRangeSelector value={value} onChange={onChange} />;
}

Hide Adjacent Dates

Hide Adjacent Dates.

  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • Su
PropTypeDefault
hideAdjacentDatesbooleanfalse
import React, { useCallback, useState } from 'react';
import { Calendar } from '@natscale/react-calendar';
import '@natscale/react-calendar/dist/main.css';
export function App() {
const [value, setValue] = useState(new Date());
const onChange = useCallback(
(val) => {
setValue(val);
},
[setValue],
);
return <Calendar hideAdjacentDates value={value} onChange={onChange} />;
}

Classname

Pass custom classnames.

PropTypeDefault
classNamestring
import React, { useCallback, useState } from 'react';
import { Calendar } from '@natscale/react-calendar';
import '@natscale/react-calendar/dist/main.css';
export function App() {
const [value, setValue] = useState(new Date());
const onChange = useCallback(
(val) => {
setValue(val);
},
[setValue],
);
return <Calendar className="my-class" value={value} onChange={onChange} />;
}

Initial View

Todo

PropTypeDefaultEnum
initialViewenum"month_dates""years", "months", "month_dates"
import React, { useCallback, useState } from 'react';
import { Calendar } from '@natscale/react-calendar';
import '@natscale/react-calendar/dist/main.css';
export function App() {
const [value, setValue] = useState(new Date());
const onChange = useCallback(
(val) => {
setValue(val);
},
[setValue],
);
return <Calendar initialView="years" value={value} onChange={onChange} />;
}

Custom Dates Disabled

Todo

  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • Su
PropTypeDefault
isDisabled(date: Date) => boolean
import React, { useCallback, useState } from 'react';
import { Calendar } from '@natscale/react-calendar';
import '@natscale/react-calendar/dist/main.css';
export function App() {
const [value, setValue] = useState(new Date());
const onChange = useCallback(
(val) => {
setValue(val);
},
[setValue],
);
const isDisabled = useCallback((date) => {
// disable wednesdays and any date that is divisible by 5
if (date.getDay() === 3 || date.getDate() % 5 === 0) {
return true;
}
}, []);
return <Calendar isDisabled={isDisabled} value={value} onChange={onChange} />;
}

Custom Dates Highlight

Todo

  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • Su
PropTypeDefault
isHighlight(date: Date) => boolean
import React, { useCallback, useState } from 'react';
import { Calendar } from '@natscale/react-calendar';
import '@natscale/react-calendar/dist/main.css';
export function App() {
const [value, setValue] = useState(new Date());
const onChange = useCallback(
(val) => {
setValue(val);
},
[setValue],
);
const isHighlight = useCallback((date) => {
// highlight any data that is divisible by 5
if (date.getDate() % 5 === 0) {
return true;
}
}, []);
return <Calendar isHighlight={isHighlight} value={value} onChange={onChange} />;
}

Lock View

Todo

  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • Su
PropTypeDefault
lockViewbooleanfalse
import React, { useCallback, useState } from 'react';
import { Calendar } from '@natscale/react-calendar';
import '@natscale/react-calendar/dist/main.css';
export function App() {
const [value, setValue] = useState(new Date());
const onChange = useCallback(
(val) => {
setValue(val);
},
[setValue],
);
return <Calendar lockView value={value} onChange={onChange} />;
}

Dark Mode

Enable/Disable dark mode.

  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • Su
PropTypeDefault
useDarkModebooleanfalse
import React, { useCallback, useState } from 'react';
import { Calendar } from '@natscale/react-calendar';
import '@natscale/react-calendar/dist/main.css';
export function App() {
const [value, setValue] = useState(new Date());
const onChange = useCallback(
(val) => {
setValue(val);
},
[setValue],
);
return <Calendar useDarkMode value={value} onChange={onChange} />;
}

Size Control

Enable/Disable dark mode.

  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • Su
PropTypeDefault
fontSizenumber16
sizenumber276
import React, { useCallback, useState } from 'react';
import { Calendar } from '@natscale/react-calendar';
import '@natscale/react-calendar/dist/main.css';
export function App() {
const [value, setValue] = useState(new Date());
const onChange = useCallback(
(val) => {
setValue(val);
},
[setValue],
);
return <Calendar size={420} fontSize={18} value={value} onChange={onChange} />;
}