Skip to content

DatePicker

A date for a form, typed in the locale’s format or chosen on a calendar; DateRangePicker does the same for a period. For a dashboard’s period filter, use DateRangeFilter.

Language
Appearance

Date

Appointment date
Weekdays only.
import { getLocalTimeZone, isWeekend, today } from '@internationalized/date';
import { useLocale } from 'react-aria-components';
import { DatePicker } from '@arbol-ai/ui';

const AppointmentExample = () => {
  const { locale } = useLocale();
  return (
    <DatePicker
      className="max-w-xs"
      description="Weekdays only."
      firstDayOfWeek="mon"
      isDateUnavailable={(date) => isWeekend(date, locale)}
      label="Appointment date"
      minValue={today(getLocalTimeZone())}
    />
  );
};

<AppointmentExample />

Date and time in 24 hours

Send the reminder at
import { getLocalTimeZone, now } from '@internationalized/date';
import { DatePicker } from '@arbol-ai/ui';

<DatePicker
  className="max-w-xs"
  defaultValue={now(getLocalTimeZone())}
  granularity="minute"
  hideTimeZone
  hourCycle={24}
  label="Send the reminder at"
/>

Period

Campaign dates
The agent calls contacts only between these days.
import { getLocalTimeZone, today } from '@internationalized/date';
import { DateRangePicker } from '@arbol-ai/ui';

() => {
  const start = today(getLocalTimeZone());
  return (
    <DateRangePicker
      className="max-w-sm"
      defaultValue={{ start, end: start.add({ weeks: 2 }) }}
      description="The agent calls contacts only between these days."
      label="Campaign dates"
    />
  );
}

Source

The examples above are src/components/date-picker/date-picker.examples.tsx, which the library’s tests render too.

Type to search…

↑↓ navigate↵ selectEsc close