CalendarDatePicker
CalendarDatePicker is a single-date picker built around the native HTML date input. It is intentionally lightweight and works without custom JavaScript.
Use DateRangePicker when users need a start and end date. Use CalendarDatePicker when users choose one date, such as a publish date, appointment date, or filter date.
Import
Basic Usage
Date Limits
CalendarDatePicker(
"appointment_date",
label="Appointment date",
min_date="2026-05-01",
max_date="2026-05-31",
)
HTMX Filtering
CalendarDatePicker(
"day",
label="Activity day",
endpoint="/activity",
hx_target="#activity-feed",
auto=True,
push_url=True,
)
When auto=True, the picker submits after the selected date changes.
With Clear Button
Parameters
| Param | Type | Default | Description |
|---|---|---|---|
name |
str |
"date" |
Input name. |
label |
str |
"Date" |
Label shown above the date input. |
value |
str \| None |
None |
Initial date in YYYY-MM-DD format. |
min_date |
str \| None |
None |
Earliest selectable date. |
max_date |
str \| None |
None |
Latest selectable date. |
endpoint |
str \| None |
None |
Optional form/HTMX endpoint. |
method |
get \| post |
"get" |
Submission method. |
auto |
bool |
False |
Submit on date change when an endpoint is present. |
apply_label |
str \| None |
"Apply" |
Submit button label. Set to None to hide. |
clear_label |
str \| None |
None |
Optional reset button label. |
apply_cls / clear_cls |
str \| None |
None |
Extra classes for the Apply/Clear buttons (e.g. btn-sm). |
hx_target |
str \| None |
None |
HTMX target for responses. |
hx_swap |
str \| None |
"outerHTML" |
HTMX swap style. |
push_url |
bool |
False |
Whether HTMX should push the URL. |
input_cls / form_cls |
str \| None |
None |
Styling hooks. |
**kwargs |
Any |
Extra wrapper attributes. |
The input control and the action buttons share one horizontal baseline; GET forms submit via the query string.
faststrap.components.forms.calendar_date_picker.CalendarDatePicker(name='date', *, label='Date', value=None, min_date=None, max_date=None, endpoint=None, method='get', auto=False, apply_label='Apply', clear_label=None, hx_target=None, hx_swap='outerHTML', push_url=False, input_cls=None, form_cls=None, apply_cls=None, clear_cls=None, **kwargs)
Render a single date picker around the native HTML date input.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Input |
'date'
|
label
|
str
|
Label shown above the date input. |
'Date'
|
value
|
str | None
|
Initial date in |
None
|
min_date
|
str | None
|
Earliest selectable date. |
None
|
max_date
|
str | None
|
Latest selectable date. |
None
|
endpoint
|
str | None
|
Optional form/HTMX endpoint. |
None
|
method
|
CalendarMethod
|
Submission method. |
'get'
|
auto
|
bool
|
Submit on date change when an endpoint is present. |
False
|
apply_label
|
str | None
|
Submit button label; |
'Apply'
|
clear_label
|
str | None
|
Optional reset button label. |
None
|
hx_target
|
str | None
|
HTMX target for responses. |
None
|
hx_swap
|
str | None
|
HTMX swap style. |
'outerHTML'
|
push_url
|
bool
|
Whether HTMX should push the URL. |
False
|
input_cls
|
str | None
|
Extra classes for the date input. |
None
|
form_cls
|
str | None
|
Extra classes for the wrapping form row. |
None
|
apply_cls
|
str | None
|
Extra classes for the Apply button. |
None
|
clear_cls
|
str | None
|
Extra classes for the Clear button. |
None
|
**kwargs
|
Any
|
Additional HTML attributes for the wrapper. |
{}
|
Source code in src/faststrap/components/forms/calendar_date_picker.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |