bootstack.Snackbar#

class bootstack.Snackbar(message, *, action=None, on_action=None, align='center', duration=5000, accent=None, on_dismiss=None)#

Bases: object

A transient message at the app window’s bottom edge with one action.

A snackbar belongs to the app, not the screen: it slides up from the bottom of the window and moves with it. It is for brief, in-context feedback that may offer a single response — the classic “Message archived. [Undo]”. Only one snackbar shows at a time; showing another replaces it. Build it, then call show().

Parameters:
  • message (str) – Body text of the snackbar.

  • action (str | None) – Label for the optional action button (e.g. 'Undo'). Omit for a message with no action.

  • on_action (Callable[[], Any] | None) – Called with no arguments when the action button is pressed. The snackbar dismisses afterward.

  • align (SnackbarAlign) – Horizontal placement along the window’s bottom edge — 'left', 'center', or 'right'. Defaults to 'center'.

  • duration (int) – Time on screen in milliseconds before it auto-dismisses. Defaults to 5000.

  • accent (AccentToken | str | None) – Semantic color accent for the action button (the surface stays neutral — severity coloring belongs to toast/Notification). Defaults to 'primary'. No effect without an action.

  • on_dismiss (Callable[[], Any] | None) – Called with no arguments when the snackbar dismisses (whether by timeout, the action, or dismiss()).

dismiss()#

Dismiss the snackbar immediately.

show()#

Display the snackbar, replacing any current one. Returns self.