Cellule de jour personnalisée

Personnalisez la façon dont chaque jour est rendu à l’aide des accessoires de rendu « Grid » et « Day ». Cela vous permet d’ajouter des indicateurs d’événement, un style personnalisé ou tout contenu supplémentaire aux cellules journalières individuelles.

import { useState } from "react";
import { DatePicker } from "react-date-range-picker-tailwind4";
const eventDates = new Set([5, 12, 18, 25]);
function CompoundCustomDay() {
const [value, setValue] = useState<Date | null>(null);
return (
<DatePicker.Root value={value} onChange={setValue} inline>
<DatePicker.Content>
<DatePicker.Header>
<DatePicker.PrevButton />
<DatePicker.Title />
<DatePicker.NextButton />
</DatePicker.Header>
<DatePicker.Grid>
{({ date }) => (
<DatePicker.Day date={date}>
{({ day, isDisabled, isSelected, isToday, onClick, onMouseEnter, onMouseLeave }) => (
<button
type="button"
onClick={onClick}
onMouseEnter={onMouseEnter}
onMouseLeave={onMouseLeave}
disabled={isDisabled}
style={{
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
width: 36,
height: 36,
border: "none",
borderRadius: 6,
cursor: isDisabled ? "default" : "pointer",
background: isSelected ? "#3b82f6" : "transparent",
color: isSelected ? "#fff" : isToday ? "#2563eb" : undefined,
fontWeight: isToday || isSelected ? 600 : 400,
fontSize: 13,
position: "relative",
}}
>
{day}
{eventDates.has(date.getDate()) && (
<span
style={{
position: "absolute",
bottom: 2,
width: 4,
height: 4,
borderRadius: "50%",
background: isSelected ? "#fff" : "#f59e0b",
}}
/>
)}
</button>
)}
</DatePicker.Day>
)}
</DatePicker.Grid>
</DatePicker.Content>
</DatePicker.Root>
);
}
March 2026
Su
Mo
Tu
We
Th
Fr
Sa

Accessoires de rendu de jour

PropTypeDescription
dateDateThe date object
daynumberDay of month (1-31)
isTodaybooleanWhether this is today
isSelectedbooleanWhether this day is selected
isDisabledbooleanWhether this day is disabled
isInRangebooleanWhether this day is within a selected range
isRangeStartbooleanWhether this is the range start
isRangeEndbooleanWhether this is the range end
isInHoverRangebooleanWhether this day is in the hover preview range
isHoverTargetbooleanWhether this is the hover endpoint
isOutsideDaybooleanWhether this day belongs to an adjacent month
isHighlightedbooleanWhether this day has a highlight dot
isFocusedbooleanWhether this day has keyboard focus
onClick() => voidClick handler
onMouseEnter() => voidMouse enter handler
onMouseLeave() => voidMouse leave handler