Celda de Día Personalizada
Personaliza cómo se renderiza cada día usando las render props Grid y Day. Esto te permite añadir indicadores de eventos, estilos personalizados o cualquier contenido extra a las celdas de días individuales.
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
Render Props del Día
| Prop | Tipo | Descripción |
|---|---|---|
date | Date | El objeto de fecha |
day | number | Día del mes (1-31) |
isToday | boolean | Si este es el día de hoy |
isSelected | boolean | Si este día está seleccionado |
isDisabled | boolean | Si este día está deshabilitado |
isInRange | boolean | Si este día está dentro de un rango seleccionado |
isRangeStart | boolean | Si este es el inicio del rango |
isRangeEnd | boolean | Si este es el final del rango |
isInHoverRange | boolean | Si este día está en el rango de vista previa flotante |
isHoverTarget | boolean | Si este es el punto final del hover |
isOutsideDay | boolean | Si este día pertenece a un mes adyacente |
isHighlighted | boolean | Si este día tiene un punto de resaltado |
isFocused | boolean | Si este día tiene el foco del teclado |
onClick | () => void | Manejador de clic |
onMouseEnter | () => void | Manejador de entrada del ratón |
onMouseLeave | () => void | Manejador de salida del ratón |