Calendar
A month-grid date picker. It collects a single normalized ISO YYYY-MM-DD
string and, with no default, opens on today.
use DrevOps\Tui\Model\Weekday;
$p->calendar('harvest', 'Harvest date')
->default('2026-07-15') // Date the grid opens on.
->minDate('2026-01-01') // Earliest selectable date, inclusive.
->maxDate('2026-12-31') // Latest selectable date, inclusive.
->weekStart(Weekday::Sunday); // Day the week grid starts on.
Runnable script: playground/02-widgets/calendar.php.
Options
| Name | Description | Required | Default |
|---|---|---|---|
default() | Date the grid opens on, as YYYY-MM-DD. | No | Today |
minDate() | Earliest selectable date, inclusive, as YYYY-MM-DD. | No | Unbounded |
maxDate() | Latest selectable date, inclusive, as YYYY-MM-DD. | No | Unbounded |
weekStart() | Day the week grid starts on, a Weekday enum case. | No | Weekday::Monday |
Navigation is clamped to the minDate()/maxDate() range: the cursor never
leaves it, days outside it render dimmed, and an opening date outside the range
snaps to the nearest bound. These are the widget's own options; the shared field
options (required(), when(), validate(), ...) are covered in
Field behaviour.
Keyboard
| Key | Action |
|---|---|
← / → | Move one day (vim: h / l) |
↑ / ↓ | Move one week (vim: k / j) |
PageUp / PageDown | Previous / next month |
Home / End | First / last day of the visible month |
Enter | Accept the highlighted date |
Esc | Cancel |
Every move key can be remapped through the key map.
Headless behaviour
The bounds are enforced when the form runs headlessly
too - a value outside the range is rejected - and surface in the JSON schema as
min_date, max_date and week_start on the prompt.
Display modes
In all four display modes - Unicode or ASCII, colour on or off:
| ANSI | No ANSI | |
| Unicode | ||
| ASCII |