Skip to the page content

Date pickers

Date fields for a single day, a range, several days, a month or a week, all usable from the keyboard.

11 date pickers

Date picker

The everyday date field: click it or its calendar button to pick a day, or type one such as Oct 14, 10/14 or tomorrow. Shown empty, with a value, disabled, and with an error. Use it for any single date that has no special rules.

Single date

Click to pick a day.

Set when the visit was closed.

Locked once the contract is signed.

Weekdays and Saturdays only.

No visits on Sundays.

Show code
<div class="basalt-datepicker" data-basalt-datepicker data-min="2026-10-08">
  <div class="input-group">
    <input type="text" class="form-control" id="visit" placeholder="Pick a date">
    <button type="button" class="btn btn-outline-secondary basalt-datepicker-btn"
            aria-label="Open calendar"><i class="bi bi-calendar3"></i></button>
  </div>
  <input type="hidden" name="visit" value="2026-11-20">
</div>

// basalt.js builds it; the hidden input carries 2026-11-20. Read or change it:
window.basaltDatepicker.get(el);
window.basaltDatepicker.set(el, '2026-11-27');

Typed date with calendar popup

A text field that reads typed dates such as Oct 2, 10/2, today or tomorrow, with a button (or Alt + Down) that opens a calendar. Options: min and max, blocked days with a reason read out, quick-pick days, and inline errors with a summary on submit. Use it when people may already know the date.

Single date

Soonest days

Monday to Saturday, up to 60 days ahead.

Arrival window

Evening visits are weekdays only.

Show code
const calendar = createCalendar(host, {
  earliest: soonestVisit(),         // tomorrow, or the day after once 2pm has passed
  latest: shiftDays(thisDay, 60),
  closedWhen: (d) => d.getDay() === 0 || closures.has(isoKey(d)),
  reason: (d) => closures.get(isoKey(d)), // spoken along with the day
  onPick: (day) => { field.value = dayLabel(day); panel.hide(); },
});

// A typed date meets the same rules
readTypedDate('10/2')  // Fri Oct 2
readTypedDate('oct 4') // Sun Oct 4, "No visits on Sundays"

Date range with presets

A button that opens a range calendar beside a list of presets. Pick a preset or two ends, hover to preview, then apply or cancel. Shows two months on wide screens and one on phones, and can stop at today. Use it for report and table filters.

Date range
Show code
const calendar = createCalendar(host, {
  select: 'range',
  columns: twoUp ? 2 : 1,           // a single month on a phone
  latest: thisDay,                  // reports stop at today
  onPick: ({ start, end }) => describeDraft(start, end),
});

const lastThirty = () => [shiftDays(thisDay, -29), thisDay];
calendar.selectSpan(...lastThirty()); // and the grid moves to show it

Start date plus duration

A read-only date field that only takes a date from its calendar, so it cannot be mistyped, paired with a duration stepper. The end date is worked out and shown as either changes. Use it for renewals, warranties or service intervals.

Single date

Within the last 30 days.

Back garden, plot 3

Fernhill Gardens, 120 Dock Street

Serviced
Next due

Show code
const due = shiftDays(lastService, weeks * 7);
const daysLeft = daysApart(thisDay, due);

createCalendar(host, { earliest: shiftDays(thisDay, -30), latest: thisDay });

Inline date range with a length limit

The range calendar, always open. Once the first end is picked, days past the longest allowed range (eight weeks here) gray out, and dots can mark days that matter. Use it when picking the dates is the main task on the screen.

Date range

Group dog walk, Lakeside Apparel, on Tuesdays

    Pick the first and last day of the pause.

    Show code
    createCalendar(host, {
      select: 'range',
      earliest: shiftDays(thisDay, 1),
      longestSpan: 56,                  // later days gray out once one end is set
      marker: (d) => visits.has(isoKey(d)) && 'visit day',
    });

    Split date fields

    A month select with day and year inputs, for dates people know by heart such as a birthday. Day and year take numbers only, the year can be optional, and the day is checked against the month, so February 30 is caught.

    Split fields
    Birthday

    It goes on the team calendar, so the crew can say happy birthday.

    Show code
    // Day 0 of the following month is this month's last day
    const monthLength = (m, y) => new Date(y, m, 0).getDate();
    if (day > monthLength(month, year || 2024)) {
      flag(`${monthName} only has ${monthLength(month, year || 2024)} days.`);
    }

    Month picker

    A grid of months with year arrows, for when the day does not matter. Past months are disabled, arrow keys move through the grid, and the value is stored as the first of the month.

    Month picker

    2026

    First visit
    Pick a month
    Last visit
    Pick a month
    Plan total
    $570.00

    One maintenance visit on the first Tuesday of each month, $95 each.

    Show code
    <button type="button" class="dtp-month" aria-pressed="false"
            aria-label="November 2026">Nov</button>
    
    // Kept as the month's first day
    const value = isoKey(new Date(year, month, 1)); // "2026-11-01"

    Week picker with week numbers

    One click selects a whole calendar row. The week can start on Monday or Sunday, ISO week numbers can sit beside each row, and past weeks are disabled. Use it for anything planned by the week.

    Week picker
    Week
    Pick a week
    Crew starts
    Monday of that week
    Crew cost
    $5,600.00

    Day rate $280 a person. Schedules lock the Thursday before.

    Show code
    createCalendar(host, {
      select: 'week',
      firstWeekday: 1,                  // weeks open on Monday
      showWeekNumbers: true,            // ISO 8601 numbering
      earliest: comingMonday,
    });

    Multiple date picker

    Toggles separate days on and off, with a cap (six here) and a message when it is reached. Days outside the allowed weekdays are disabled, and each pick is listed so it can be removed on its own.

    Multiple dates

    On-call days

    0 of 6

      On-call runs Fridays, Saturdays and Sundays.

      Show code
      createCalendar(host, {
        select: 'multiple',
        mostDays: 6,
        closedWhen: (d) => ![0, 5, 6].includes(d.getDay()),
        onFull: () => hint('Six days is the most for one quarter.'),
      });

      Calendar with event dots

      An inline single-day calendar where busy days carry a dot, and the count is read out with the day. Picking a day lists what falls on it. Use it when people choose a date by what is available.

      Event calendar

      Training

        Coming up after that

          Show code
          createCalendar(host, {
            earliest: thisDay,
            marker: (d) => {
              const total = sessionsOn(d).length;
              return total && `${total} session${total === 1 ? '' : 's'}`;
            },
            onPick: (day) => drawDay(day),
          });

          Native date and time inputs

          The browser's own data-native type="date" and type="time". Phones open the system wheel. Limits come from min, max and step, errors are read from the validity state, and the value is always an ISO string.

          Native input

          Within the next 30 days.

          9am to 5pm, in 15 minute steps.

          Stored as
          Nothing yet
          Shown as
          Nothing yet

          Show code
          <input data-native
          												type="date" min="2026-09-28" max="2026-10-28" required>
          <input type="time" min="09:00" max="17:00" step="900">
          
          field.validity.rangeUnderflow // true for any day before min