| Su | Mo | Tu | We | Th | Fr | Sa |
|---|---|---|---|---|---|---|
Instalación
npx logic2b@next add calendarUso
import { useState } from "react"
import { Calendar } from "@/components/ui/calendar"
const [date, setDate] = useState<Date | undefined>(new Date())
<Calendar mode="single" selected={date} onSelect={setDate} className="rounded-md border" />
Está construido sobre react-day-picker. Consulta también el selector de fecha, una composición con Popover que convierte el calendario en un campo similar a una entrada de texto.
Notas de uso
Se reenvían todas las demás propiedades DayPicker de react-day-picker.
Ejemplos
Intervalo
Usa mode="range" y guarda un DateRange en el estado para elegir los días inicial y final.
| Su | Mo | Tu | We | Th | Fr | Sa |
|---|---|---|---|---|---|---|
| Su | Mo | Tu | We | Th | Fr | Sa |
|---|---|---|---|---|---|---|
Selector de mes y año
Usa captionLayout="dropdown" para cambiar de mes y año mediante selectores.
| Su | Mo | Tu | We | Th | Fr | Sa |
|---|---|---|---|---|---|---|
Playground interactivo
Edita las propiedades del componente y revisa el JSX exacto antes de copiarlo. La vista previa se carga solo cuando esta sección entra en pantalla.
<Calendar
mode="single"
defaultMonth={new Date(2026, 7, 15)}
today={new Date(2026, 7, 15)}
selected={new Date(2026, 7, 15)}
showOutsideDays
captionLayout="label"
aria-label="August 2026 release calendar"
/>| Su | Mo | Tu | We | Th | Fr | Sa |
|---|---|---|---|---|---|---|
Referencia de API
Generada a partir de las exportaciones públicas de TypeScript en src/ui/calendar.tsx. Las descripciones técnicas conservan el texto canónico del código fuente.
Calendar
ComponenteProps: React.ComponentProps<typeof DayPicker> & { buttonVariant?: React.ComponentProps<typeof Button>["variant"] }| Propiedad | Tipo | Obligatoria | Valor predeterminado | Descripción |
|---|---|---|---|---|
showOutsideDays | boolean | No | true | Show the outside days (days falling in the next or the previous month). **Note:** when a {@link broadcastCalendar} is set, this prop defaults to true. |
captionLayout | "label" | "dropdown" | "dropdown-months" | "dropdown-years" | No | "label" | Show dropdowns to navigate between months or years. - `label`: Displays the month and year as a label. Default value. - `dropdown`: Displays dropdowns for both month and year navigation. - `dropdown-months`: Displays a dropdown only for the month navigation. - `dropdown-years`: Displays a dropdown only for the year navigation. **Note:** By default, showing the dropdown will set the {@link startMonth} to 100 years ago and {@link endMonth} to the end of the current year. You can override this behavior by explicitly setting `startMonth` and `endMonth`. |
buttonVariant | React.ComponentProps<typeof Button>["variant"] | No | "ghost" | — |
CalendarDayButton
ComponenteProps: React.ComponentProps<typeof DayButton>Contrato de accesibilidad
Comportamiento legible por máquinas y responsabilidades de quien integra calendar. Los detalles normativos conservan el texto canónico del registro.
- Soporte
- Gestionado por la primitiva
- Patrón
- date grid
- React DayPicker
| Teclas | Comportamiento |
|---|---|
| ArrowUp ArrowDown ArrowLeft ArrowRight | Move within the composite control. |
| PageUp PageDown | Move between months. |
| Home End | Move within the current week. |
| Enter Space | Select the focused date. |
Semántica incorporada
- Uses grid/gridcell semantics with labelled navigation and selected/disabled date state.
Responsabilidades de integración
- Provide a label describing the date purpose and expose format/validation guidance near related inputs.