InputTime
@solara.component
def InputTime(
value: Union[solara.Reactive[Optional[dt.time]], Optional[dt.time]],
on_value: Optional[Callable[[Optional[dt.time]], None]] = None,
label: str = "Pick a time",
children: List[solara.Element] = [],
open_value: Union[solara.Reactive[bool], bool] = False,
on_open_value: Optional[Callable[[bool], None]] = None,
optional: bool = False,
twelve_hour_clock: bool = False,
use_seconds: bool = False,
allowed_minutes: Optional[List[int]] = None,
style: Optional[Union[str, Dict[str, str]]] = None,
classes: Optional[List[str]] = None,
):
...
Show a textfield, which when clicked, opens a timepicker. The input time should be of type datetime.time
.
Basic Example
import solara
import solara.lab
import datetime as dt
@solara.component
def Page():
time = solara.use_reactive(dt.time(12, 0))
solara.lab.InputTime(time, allowed_minutes=[0, 15, 30, 45])
solara.Text(str(time.value))
Live output
Run and edit this code in Py.Cafe
Arguments
- value: Reactive variable of type
datetime.time
, orNone
. This time is selected the first time the component is rendered. - on_value: a callback function for when value changes. The callback function receives the new value as an argument.
- label: Text used to label the text field that triggers the timepicker.
- children: List of Elements to be rendered under the timepicker. If empty, a close button is rendered.
- open_value: Controls and communicates the state of the timepicker. If True, the timepicker is open. If False, the timepicker is closed. Intended to be used in conjunction with a custom set of controls to close the timepicker.
- on_open_value: a callback function for when open_value changes. Also receives the new value as an argument.
- optional: Determines whether to show an error when value is
None
. IfTrue
, no error is shown. - twelve_hour_clock: If
True
, the timepicker will display in 12-hour format. IfFalse
, the timepicker will display in 24-hour format. - use_seconds: If
True
, the timepicker will allow input of seconds. - allowed_minutes: List of allowed minutes for the timepicker. Restricts the input to specific minute intervals.
- style: CSS style to apply to the text field. Either a string or a dictionary of CSS properties (i.e.
{"property": "value"}
). - classes: List of CSS classes to apply to the text field.