duck.html.components.snackbar¶
Snackbar component for displaying brief messages at the top of the screen.
Module Contents¶
Classes¶
Snackbar component for showing brief notifications. |
Data¶
API¶
- duck.html.components.snackbar.SNACKBAR_SCRIPT = <Multiline-String>¶
- class duck.html.components.snackbar.Snackbar(text: str | None = None, type: str = 'info', variant: str = 'filled', timeout: int | None = None, **kwargs)[source]¶
Bases:
duck.html.components.container.FlexContainerSnackbar component for showing brief notifications.
Initialization
Initialize the snackbar.
- Parameters:
text – Snackbar message text.
type – Snackbar type. Must be
info,success,error, orwarning.variant – Visual style. Must be
filled(solid background) orglacier(frosted, outlined glass look).timeout – Auto-hide timeout in milliseconds.
**kwargs – Additional component keyword arguments.
- Raises:
ValueError – If the snackbar type or variant is invalid.
- _apply_variant_style() None[source]¶
Apply the background/border/text styling for the current type + variant combination.
- allowed_types¶
None
- allowed_variants¶
None
- get_type_color(type: str) str[source]¶
Return the accent color for a snackbar type.
- Parameters:
type – Snackbar type.
- Returns:
The configured CSS color for the snackbar type.
- set_timeout(timeout: int | None) None[source]¶
Set the default JavaScript auto-hide timeout.
- Parameters:
timeout – Auto-hide timeout in milliseconds, or
Noneto disable.
- set_type(type: str) None[source]¶
Set snackbar type and background color.
- Parameters:
type – Snackbar type. Must be
info,success,error, orwarning.- Raises:
ValueError – If the snackbar type is invalid.
- set_type_color(type: str, color: str) None[source]¶
Set the color for a snackbar type.
- Parameters:
type – Snackbar type.
color – CSS color value.
- Raises:
ValueError – If the snackbar type is invalid.