Widgets¶
Input widgets are used as the default value of a node parameter; Golit turns that parameter into an input node. Each has an ergonomic lowercase factory (use these) and an underlying class.
See the Inputs & widgets tutorial for usage and commit semantics.
Input widgets.
A widget is used as the default value of a node-function parameter. When Golit
introspects the signature, a parameter whose default is a :class:Widget becomes
an input node named after the parameter; everything downstream of it re-runs
when its committed value changes.
Each widget knows three things: its default value, how to coerce a posted
string into the typed Python value, and how to render its HTML control (wired
for HTMX POST + an Alpine "local shield" for high-frequency feedback).
Slider
¶
Slider(
low: float,
high: float,
*,
default: float | None = None,
step: float = 1,
label: str | None = None,
)
Bases: Widget
A numeric range slider. Commits on release (change); Alpine shows the
live value during drag without touching the server.
Source code in python/golit/widgets.py
coerce
¶
render
¶
Source code in python/golit/widgets.py
RangeSlider
¶
RangeSlider(
low: float,
high: float,
*,
default: tuple[float, float]
| list[float]
| None = None,
step: float = 1,
label: str | None = None,
)
Bases: Widget
A dual-handle slider selecting a numeric [low, high] band. Commits on
release (change); Alpine drives the live fill, value labels, and overlap
handling during the drag without touching the server.
Both handles post comma-joined into the single value, so the one-value
POST contract holds; coerce splits and returns a sorted (low, high)
tuple of numbers.
Source code in python/golit/widgets.py
coerce
¶
Source code in python/golit/widgets.py
render
¶
Source code in python/golit/widgets.py
NumberInput
¶
NumberInput(
low: float | None = None,
high: float | None = None,
*,
default: float = 0,
step: float = 1,
label: str | None = None,
prefix: str = "",
suffix: str = "",
thousands: bool = False,
)
Bases: Widget
A numeric input with optional low/high bounds. prefix/suffix add
inline adornments ("$", "%") and thousands=True groups the digits when
the value commits — turning it into a currency/percent field. With any of those set
the value coerces from the formatted string; otherwise it's a native number spinner.
Source code in python/golit/widgets.py
coerce
¶
Source code in python/golit/widgets.py
render
¶
Source code in python/golit/widgets.py
Select
¶
Bases: Widget
A dropdown of options; the value is the chosen option object.
Source code in python/golit/widgets.py
coerce
¶
render
¶
Source code in python/golit/widgets.py
ComboBox
¶
ComboBox(
options: list[Any],
*,
default: Any = None,
label: str | None = None,
placeholder: str = "Select…",
)
Bases: Widget
A searchable single-select: a trigger button plus a filterable popover. Like
:class:Select the value is the chosen option object, but the options are
searchable — better for long lookup lists (customers, SKUs, accounts). Picking
an option commits it and closes the popover.
Selection lives in a hidden field that a request-time hx-vals reads, so the
single-value POST contract holds; coerce maps the string back to the
option object exactly as :class:Select does.
Source code in python/golit/widgets.py
coerce
¶
render
¶
Source code in python/golit/widgets.py
TextInput
¶
Bases: Widget
A single-line text input. Commits on blur or after a short typing pause.
Source code in python/golit/widgets.py
coerce
¶
render
¶
Source code in python/golit/widgets.py
Checkbox
¶
Bases: Widget
A boolean checkbox. An unchecked box still commits False.
Source code in python/golit/widgets.py
coerce
¶
render
¶
Source code in python/golit/widgets.py
Upload
¶
Bases: Widget
A file upload. Coerces the posted bytes into a BytesIO that Polars
readers (pl.read_csv etc.) accept directly.
Source code in python/golit/widgets.py
coerce
¶
Source code in python/golit/widgets.py
render
¶
Source code in python/golit/widgets.py
RadioGroup
¶
Bases: Widget
A single choice from a set, shown as radio buttons. Each radio posts its own
value on change (no shared id), coerced back to the original option object.
Source code in python/golit/widgets.py
coerce
¶
render
¶
Source code in python/golit/widgets.py
Segmented
¶
Bases: Widget
A single choice shown as a compact horizontal toggle (a segmented control) —
the same value semantics as :class:RadioGroup/:class:Select, but tuned for
short option sets like Day/Week/Month. The chosen option highlights white-on-blue
and commits on click.
Selection is held in a hidden field that a request-time hx-vals reads, so the
single-value POST contract holds; coerce maps the string back to the
option object.
Source code in python/golit/widgets.py
coerce
¶
render
¶
Source code in python/golit/widgets.py
MultiSelect
¶
MultiSelect(
options: list[Any],
*,
default: list[Any] | tuple[Any, ...] = (),
label: str | None = None,
display: str = "list",
)
Bases: Widget
Zero or more choices. The default display="list" is a flat checkbox
column; display="dropdown" collapses the options into a searchable popover
(an Alpine-powered trigger plus a filterable panel) that suits long lists.
Either way a request-time hx-vals script reads the checked boxes and posts
them comma-joined, so the single-value POST contract is preserved;
coerce splits and maps back to option objects.
Source code in python/golit/widgets.py
coerce
¶
Tags
¶
Tags(
*,
default: list[Any] | tuple[Any, ...] = (),
label: str | None = None,
placeholder: str = "Add tag…",
)
Bases: Widget
A free-form token input: the user types arbitrary values and each becomes a
removable chip. Unlike :class:MultiSelect the values aren't from a fixed list —
think recipients, keywords, or ad-hoc filter terms. The value is a list[str].
Enter or comma commits the draft as a chip, Backspace on an empty field removes
the last one, and the × removes any chip. The chips are comma-joined into the
single value (so a chip can't itself contain a comma); coerce splits and
trims them back into a list.
Source code in python/golit/widgets.py
coerce
¶
render
¶
Source code in python/golit/widgets.py
Switch
¶
Bases: Widget
A boolean toggle (styled checkbox). Posts true/false via hx-vals
so an off-state still commits.
Source code in python/golit/widgets.py
coerce
¶
render
¶
Source code in python/golit/widgets.py
DateInput
¶
Bases: Widget
A native date picker. Coerces the ISO string to datetime.date (or None).
Source code in python/golit/widgets.py
coerce
¶
render
¶
Source code in python/golit/widgets.py
DateRange
¶
DateRange(
*,
default: tuple[date | None, date | None]
| list[date | None]
| None = None,
label: str | None = None,
low: date | None = None,
high: date | None = None,
presets: bool = True,
)
Bases: Widget
A start/end date range — the period filter every dashboard needs. Two native date pickers plus quick presets (7/30/90 days, MTD/QTD/YTD) computed client-side.
Both edges post comma-joined into the single value (e.g. "2026-04-01,
2026-06-30"), so the one-value POST contract holds; coerce splits them
back into a (start, end) tuple of datetime.date (either side may be
None when left blank).
Source code in python/golit/widgets.py
coerce
¶
render
¶
Source code in python/golit/widgets.py
TextArea
¶
Bases: Widget
A multi-line text input. Commits on blur or after a short typing pause.
Source code in python/golit/widgets.py
coerce
¶
render
¶
Source code in python/golit/widgets.py
Button
¶
Bases: Widget
An action trigger. Each click posts a fresh nonce (Date.now()), so the
input's value changes and the dirty subgraph re-runs — the reactive equivalent
of "on click". The value itself is a monotonic counter a node can ignore.
Source code in python/golit/widgets.py
coerce
¶
render
¶
Source code in python/golit/widgets.py
esc
¶
slider
¶
slider(
low: float,
high: float,
*,
default: float | None = None,
step: float = 1,
label: str | None = None,
) -> Slider
A numeric range slider. Commits on release; live drag feedback is client-side.
Source code in python/golit/widgets.py
rangeslider
¶
rangeslider(
low: float,
high: float,
*,
default: tuple[float, float]
| list[float]
| None = None,
step: float = 1,
label: str | None = None,
) -> RangeSlider
A dual-handle slider selecting a [low, high] band; the value is a sorted
(low, high) tuple. Commits on release; live drag feedback is client-side.
Source code in python/golit/widgets.py
number
¶
number(
low: float | None = None,
high: float | None = None,
*,
default: float = 0,
step: float = 1,
label: str | None = None,
prefix: str = "",
suffix: str = "",
thousands: bool = False,
) -> NumberInput
A numeric input with optional low/high bounds. prefix/suffix add
adornments ("$", "%") and thousands=True groups the digits on commit —
together a currency/percent field.
Source code in python/golit/widgets.py
select
¶
select(
options: list[Any],
*,
default: Any = None,
label: str | None = None,
) -> Select
A dropdown of options; the value is the chosen option object.
combobox
¶
combobox(
options: list[Any],
*,
default: Any = None,
label: str | None = None,
placeholder: str = "Select…",
) -> ComboBox
A searchable single-select; the value is the chosen option object. Like
select but with a filterable popover — better for long lookup lists.
Source code in python/golit/widgets.py
text
¶
text(
*,
default: str = "",
label: str | None = None,
placeholder: str = "",
) -> TextInput
A single-line text input. Commits on blur or after a short typing pause.
checkbox
¶
checkbox(
*, default: bool = False, label: str | None = None
) -> Checkbox
A boolean checkbox. An unchecked box still commits False.
upload
¶
upload(
label: str | None = None, *, accept: str | None = None
) -> Upload
A file upload, coerced to a BytesIO Polars readers accept. None until
a file is chosen; accept filters the picker (e.g. ".csv").
Source code in python/golit/widgets.py
radio
¶
radio(
options: list[Any],
*,
default: Any = None,
label: str | None = None,
) -> RadioGroup
A single choice from options, shown as radio buttons.
segmented
¶
segmented(
options: list[Any],
*,
default: Any = None,
label: str | None = None,
) -> Segmented
A single choice as a compact horizontal toggle (segmented control); the value is the chosen option object. Best for short sets like Day/Week/Month.
Source code in python/golit/widgets.py
multiselect
¶
multiselect(
options: list[Any],
*,
default: list[Any] | tuple[Any, ...] = (),
label: str | None = None,
display: str = "list",
) -> MultiSelect
Zero or more of options; the value is a list. display="list"
(default) is a checkbox column; display="dropdown" is a searchable popover.
Source code in python/golit/widgets.py
tags
¶
tags(
*,
default: list[Any] | tuple[Any, ...] = (),
label: str | None = None,
placeholder: str = "Add tag…",
) -> Tags
A free-form token input; the value is a list[str] of the chips. Enter or
comma adds a chip, Backspace on an empty field removes the last, × removes any.
Source code in python/golit/widgets.py
switch
¶
switch(
label: str | None = None, *, default: bool = False
) -> Switch
A boolean toggle (styled checkbox). An off state still commits False.
date
¶
date(
*, default: date | None = None, label: str | None = None
) -> DateInput
A native date picker; the value is a datetime.date (or None).
daterange
¶
daterange(
*,
default: tuple[date | None, date | None]
| list[date | None]
| None = None,
label: str | None = None,
low: date | None = None,
high: date | None = None,
presets: bool = True,
) -> DateRange
A start/end date range with quick presets; the value is a
(start, end) tuple of datetime.date (either side may be None).
low/high bound the pickers; presets=False hides the quick chips.
Source code in python/golit/widgets.py
textarea
¶
textarea(
*,
default: str = "",
label: str | None = None,
placeholder: str = "",
rows: int = 4,
) -> TextArea
A multi-line text input. Commits on blur or after a short typing pause.