Content switcher
ContentSwitcher
¶
Bases: Container
A widget for switching between different children.
Note
All child widgets that are to be switched between need a unique ID. Children that have no ID will be hidden and ignored.
current: reactive[str | None]
class-attribute
¶
The ID of the currently-displayed widget.
If set to None
then no widget is visible.
Note
If set to an unknown ID, this will result in NoMatches being raised.
visible_content: Widget | None
property
¶
A reference to the currently-visible widget.
None
if nothing is visible.
__init__(*children, name=None, id=None, classes=None, disabled=False, initial=None)
¶
Initialise the content switching widget.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*children |
Widget
|
The widgets to switch between. |
()
|
name |
str | None
|
The name of the content switcher. |
None
|
id |
str | None
|
The ID of the content switcher in the DOM. |
None
|
classes |
str | None
|
The CSS classes of the content switcher. |
None
|
disabled |
bool
|
Whether the content switcher is disabled or not. |
False
|
initial |
str | None
|
The ID of the initial widget to show, |
None
|
Note
If initial
is not supplied no children will be shown to start with.
on_mount()
¶
Perform the initial setup of the widget once the DOM is ready.