Skip to content
Block Kit for React
Esc
↑↓navigate↵open⌘Jpreview
On this page

Date picker element

A calendar control for choosing a single date, rendered like Slack's datepicker.

datepicker opens a calendar popup for choosing one date. Use it in an actions block or a section’s accessory for a quick date pick, or in an input block to collect a date in a modal.

As in Slack, you can also type a date into the field: 05/01/1990, 5/1/90, 1990-05-01, May 1, 1990 or the field’s own long form, May 1st, 1990. Enter takes it and keeps the calendar open, leaving the field takes it too, and text that isn’t a date is ignored. Escape drops what you typed, puts the chosen date back and closes the calendar.

Your AppAPP
onActionInteract with the preview.

Fields

PropType
typestring

Always datepicker.

Typestring
action_id?string

Identifies this element in the block_actions payload. Must be unique within a block.

Typestring
initial_date?string

The date selected when the element loads, as YYYY-MM-DD.

Typestring
placeholder?PlainTextElement

Text shown when no date is selected. Slack limits it to 150 characters.

TypePlainTextElement
confirm?ConfirmationDialog

A confirmation dialog shown before the pick (or clear) takes effect.

TypeConfirmationDialog
focus_on_load?boolean

Focuses this element when its modal or Home tab loads. Only one element per view. Slack ignores it in messages.

Typeboolean
Defaultfalse

Like Slack, the field comes in two sizes: the compact 28px field in messages, and the 36px field with 15px text in modals and on App Home.

Examples

Without an initial value

Empty until the user picks a date. The input shows the placeholder text, or “Select a date” if none is given.

Your AppAPP
onActionInteract with the preview.

With an initial value

Outside an input block, the closed control shows the date as Slack does on the web: MM/DD/YYYY.

Your AppAPP
onActionInteract with the preview.

Inside an input block

An input block spells the date out instead, e.g. “April 28th, 1990”:

Your AppAPP
Label

With a confirmation dialog

Your AppAPP
onActionInteract with the preview.

The dialog appears before a pick (or a “Clear selection”) takes effect; declining leaves the element unchanged.

Interactivity

Picking a day fires an action with selected_date. Where the date may be left empty, the calendar also has Slack’s “Clear selection” footer once a date is set, and clearing sends null. That’s an optional input block, or any input block in a message, where Slack treats inputs as optional:

{
  "type": "datepicker",
  "action_id": "select_date",
  "block_id": "trip",
  "selected_date": "2024-06-20"
}

The same shape lands in state.values[block_id][action_id] for reading back later, e.g. from a view_submission payload:

{
  "type": "datepicker",
  "selected_date": "2024-06-20"
}

When initial_date is set, the action carries it too ("initial_date": "2024-06-01"), as Slack’s does; the placeholder isn’t sent. The initial value is also reported as state as soon as the element mounts. You don’t need an interaction first to read it back.

Time zone

A date picker sends a calendar day ("selected_date": "2024-06-01") with no time or zone, so the provider’s timeZone doesn’t change what it sends or shows. The calendar marks today by the viewer’s own clock. The datetime picker is the one that reads timeZone.

Keyboard

As in Slack, the calendar opens with its right edge on the field’s (on a screen too narrow for that, it shifts just enough to stay inside the window), and opening it with a click focuses the selected day (or today). Tabbing into the field selects its date and leaves the calendar closed, as Slack’s does, so you can type over it or Tab on; the next Tab reaches the field’s own “Open calendar” button, which opens the calendar on the selected day. Typing opens the calendar, and ArrowDown in the field opens it and moves in, which Slack’s field doesn’t do; it’s kept as a shortcut. There, the arrow keys move a day left or right and a week up or down, turning the month when they cross its edge, and Enter picks the focused day. The day the calendar opens on looks like any other until the pointer or the keyboard reaches it, as in Slack; a day the keyboard moves to gets Slack’s hover look (a light-blue border, and a light-blue wash unless it’s the selected day) and the focus ring. Each day is named in full for screen readers (“Saturday, April 28th, 1990”), as in Slack. The month grid is a single tab stop. Picking a day with Enter or Space, or pressing Escape, closes the calendar and returns focus to the field. Picking one with a click closes it and leaves nothing focused, as in Slack, so the field doesn’t keep its focus ring. The datetime picker’s calendar uses the same arrow keys.

Last updated on