Skip to content
loseta

Recipes

Date picker

A date picker is a trigger, a popover and a calendar. The registry provides the pieces; opening the panel, selecting a date and formatting the value are consumer JavaScript.

Recipe, not a registry item. Install the pieces withloseta add popover button calendar. There is no date-picker class to install and no calendar engine in the CSS.

Open picker

Default

February 2026
February 2026
Su Mo Tu We Th Fr Sa
<div style="display: flex; min-height: 22rem; align-items: flex-start; justify-content: center">
  <div class="popover" style="width: 18rem; flex-direction: column; align-items: stretch">
    <button type="button" class="btn" data-variant="outline" aria-expanded="true" aria-controls="recipe-date-panel" style="width: 100%; justify-content: space-between">
      <span style="display: inline-flex; align-items: center; gap: 0.5rem">
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 2v4"/><path d="M16 2v4"/><rect width="18" height="18" x="3" y="4" rx="2"/><path d="M3 10h18"/></svg>
        February 14, 2026
      </span>
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m6 9 6 6 6-6"/></svg>
    </button>
    <div data-popover data-side="bottom" aria-hidden="false" id="recipe-date-panel" style="width: 18rem">
      <div class="calendar" style="width: 100%">
        <header>
          <button type="button" aria-label="Previous month">
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m15 18-6-6 6-6"/></svg>
          </button>
          <span data-slot="title" aria-live="polite">February 2026</span>
          <button type="button" aria-label="Next month">
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m9 18 6-6-6-6"/></svg>
          </button>
        </header>
        <table role="grid">
          <caption class="sr-only">February 2026</caption>
          <thead>
            <tr>
              <th scope="col"><abbr title="Sunday">Su</abbr></th>
              <th scope="col"><abbr title="Monday">Mo</abbr></th>
              <th scope="col"><abbr title="Tuesday">Tu</abbr></th>
              <th scope="col"><abbr title="Wednesday">We</abbr></th>
              <th scope="col"><abbr title="Thursday">Th</abbr></th>
              <th scope="col"><abbr title="Friday">Fr</abbr></th>
              <th scope="col"><abbr title="Saturday">Sa</abbr></th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td role="gridcell" aria-selected="false"><button type="button" aria-label="February 8, 2026">8</button></td>
              <td role="gridcell" aria-selected="false"><button type="button" aria-label="February 9, 2026">9</button></td>
              <td role="gridcell" aria-selected="false"><button type="button" aria-label="February 10, 2026">10</button></td>
              <td role="gridcell" aria-selected="false"><button type="button" aria-label="February 11, 2026">11</button></td>
              <td role="gridcell" aria-selected="false"><button type="button" aria-label="February 12, 2026">12</button></td>
              <td role="gridcell" aria-selected="false"><button type="button" aria-label="February 13, 2026">13</button></td>
              <td role="gridcell" aria-selected="true"><button type="button" aria-label="February 14, 2026">14</button></td>
            </tr>
            <tr>
              <td role="gridcell" aria-selected="false"><button type="button" aria-label="February 15, 2026">15</button></td>
              <td role="gridcell" aria-selected="false"><button type="button" aria-label="February 16, 2026">16</button></td>
              <td role="gridcell" aria-selected="false"><button type="button" aria-label="February 17, 2026">17</button></td>
              <td role="gridcell" aria-selected="false"><button type="button" aria-label="February 18, 2026">18</button></td>
              <td role="gridcell" aria-selected="false"><button type="button" aria-label="February 19, 2026">19</button></td>
              <td role="gridcell" aria-selected="false"><button type="button" aria-label="February 20, 2026">20</button></td>
              <td role="gridcell" aria-selected="false"><button type="button" aria-label="February 21, 2026">21</button></td>
            </tr>
          </tbody>
        </table>
      </div>
    </div>
  </div>
</div>

Composition

The trigger is a button with aria-expanded andaria-controls. The panel is a [data-popover] containing a calendar. The docs demo toggles the panel; a production date picker also moves focus into the calendar, closes on selection and returns focus to the trigger.

html
<div class="popover">
  <button class="btn" data-variant="outline"
    aria-expanded="false" aria-controls="due-date">
    Choose a date
  </button>
  <div data-popover data-side="bottom" aria-hidden="true" id="due-date">
    <div class="calendar">
      <!-- header, grid and day buttons -->
    </div>
  </div>
</div>

Calendar state

  • The month grid is a native <table role="grid">; headers usescope="col" and day cells use role="gridcell".
  • Selected cells use aria-selected="true"; today usesaria-current="date"; unavailable days usearia-disabled="true".
  • Day buttons need full-date accessible names, not just the day number.
  • Month navigation, keyboard grid movement and the displayed month are consumer JavaScript. The registry does not ship a date library.

Formatting

Format the visible value for the user's locale with Intl.DateTimeFormator your date library. Keep the submitted value in an ISO format in a hidden input or in your form state; do not parse the visible label.

js
const label = new Intl.DateTimeFormat(undefined, {
  dateStyle: "long"
}).format(value);

loseta is MIT licensed. Built with native CSS, no runtime. Inspired byshadcn/ui.