Saltar al contenido
Logic2BUI

Buscar en la documentación

Busca componentes y documentación

Nuevo
Menú

Calendario

Campo de fecha con una cuadrícula para elegir un día, varios días o un intervalo.

October 2026

Instalación

npx logic2b@next add calendar

Uso

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.

October 2026
November 2026

Selector de mes y año

Usa captionLayout="dropdown" para cambiar de mes y año mediante selectores.

October 2026

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.

JSX generado
<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"
 />

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.

Ver JSON

Calendar

Componente
Props: React.ComponentProps<typeof DayPicker> & { buttonVariant?: React.ComponentProps<typeof Button>["variant"] }
PropiedadTipoObligatoriaValor predeterminadoDescripción
showOutsideDaysbooleanNotrueShow 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`.
buttonVariantReact.ComponentProps<typeof Button>["variant"]No"ghost"—

CalendarDayButton

Componente
Props: 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.

Ver JSON
Soporte
Gestionado por la primitiva
Patrón
date grid
React DayPicker
Interacciones de teclado para calendar
TeclasComportamiento
ArrowUp ArrowDown ArrowLeft ArrowRightMove within the composite control.
PageUp PageDownMove between months.
Home EndMove within the current week.
Enter SpaceSelect 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.