Skip to content

Button

pywry.toolbar.Button

Bases: ToolbarItem

A clickable button that emits an event with optional data payload.

ATTRIBUTE DESCRIPTION
variant

Button style variant. Options: "primary" (theme-aware), "secondary" (subtle), "neutral" (blue), "ghost" (transparent), "outline" (bordered), "danger" (red), "warning" (orange), "icon" (ghost style, square aspect ratio).

TYPE: str

size

Button size variant. Options: None (default), "xs", "sm", "lg", "xl".

TYPE: str or None

data

Additional data payload to include with the event.

TYPE: dict

Examples:

>>> Button(label="Export", event="export:csv", data={"format": "csv"})
>>> Button(label="Cancel", event="app:cancel", variant="secondary")
>>> Button(label="⚙", event="app:settings", variant="icon")
>>> Button(label="Submit", event="form:submit", variant="neutral", size="lg")

Functions

build_html

build_html() -> str

Build button HTML.

auto_generate_component_id

auto_generate_component_id() -> ToolbarItem

Auto-generate component_id based on type if not provided.

validate_event_name classmethod

validate_event_name(v: str) -> str

Validate event follows namespace:event-name pattern.