Calendar
A month-grid date picker. It collects a single normalized ISO YYYY-MM-DD string; give it no default and it 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 behavior.
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 |
The day and week moves resolve through the key map, so the arrows and the vim letters can be remapped; the month and edge jumps (PageUp/PageDown, Home/End) are fixed keys with no action behind them.
Headless behavior
The bounds are enforced when the form runs headlessly too - a value outside the range is rejected - and they 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, color on or off:
| ANSI | No ANSI | |
| Unicode | ||
| ASCII |