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
| Prop | Type | Description |
|---|---|---|
date | Date | The date object |
day | number | Day of month (1-31) |
isToday | boolean | Whether this is today |
isSelected | boolean | Whether this day is selected |
isDisabled | boolean | Whether this day is disabled |
isInRange | boolean | Whether this day is within a selected range |
isRangeStart | boolean | Whether this is the range start |
isRangeEnd | boolean | Whether this is the range end |
isInHoverRange | boolean | Whether this day is in the hover preview range |
isHoverTarget | boolean | Whether this is the hover endpoint |
isOutsideDay | boolean | Whether this day belongs to an adjacent month |
isHighlighted | boolean | Whether this day has a highlight dot |
isFocused | boolean | Whether this day has keyboard focus |
onClick | () => void | Click handler |
onMouseEnter | () => void | Mouse enter handler |
onMouseLeave | () => void | Mouse leave handler |