quirl.components.alert¶
A contextual alert banner for notifications and feedback.
Module Contents¶
Classes¶
A contextual alert banner for notifications and feedback. |
Data¶
API¶
- class quirl.components.alert.Alert(element: Optional[str] = None, properties: Optional[Dict[str, str]] = None, props: Optional[Dict[str, str]] = None, style: Optional[Dict[str, str]] = None, inner_html: Optional[Union[str, str, float]] = None, children: Optional[List[duck.html.components.HtmlComponent]] = None, **kwargs)[source]¶
Bases:
duck.html.components.container.ContainerA contextual alert banner for notifications and feedback.
Supports info, success, warning, and error variants with theme-aware color mapping and an optional dismiss button.
Usage:
Alert( title="Heads up", description="Your changes have been saved.", variant="success", dismissible=True, )
Required Props:
description: The alert message body
Optional Props:
title: Optional bold heading above the description
variant: One of info, success, warning, error. Defaults to info.
dismissible: Show a close button. Defaults to False.
Initialization
Initialize an HTML component.
- Parameters:
element – The HTML element tag name (e.g., textarea, input, button). Can be None, but make sure element is returned by get_element method.
accept_inner_html – Whether the HTML component accepts an inner body (e.g., inner-body-here).
inner_html – Inner html to add to the HTML component. Defaults to None.
properties – Dictionary for properties to initialize the component with.
props – Just same as properties argument (added for simplicity).
style – Dictionary for style to initialize the component with.
event_handlers – Events to automatically bind. Each dictionary maps an event name to its handler and may include additional keyword arguments forwarded to
bind(), e.g.event_handlers=[{"click": on_button_click, **extra_kwargs}].**kwargs – Extra keyword arguments
- Raises:
HtmlComponentError – If ‘element’ is not a string or ‘inner_html’ is set but ‘accept_inner_html’ is False.
- build_body() duck.html.components.container.Container[source]¶
Build the title and description column.
- Returns:
A Container holding the alert’s text content.
- build_dismiss_button() duck.html.components.button.Button[source]¶
Build the close button for dismissible alerts.
- Returns:
A styled Button component that hides the alert on click.
- docs_animation_steps¶
None
- docs_preview_kwargs¶
None
- quirl.components.alert.VARIANT_TOKEN_MAP¶
None