Toast Trigger
Installation
Included in poetry-ui — available as
poetry_toast_trigger
the moment you've installed Poetry,
with no per-component step. To own the source and edit it, copy it into your app:
bin/rails g poetry:add toast-trigger
Default
<%# The stamp pattern end-to-end: the trigger, the <template> holding one
rendered toast (byte-for-byte what a Turbo Stream would append), and
the viewport region it lands in. duration: auto-dismisses. %>
<div>
<%= poetry_toast_trigger(template: "trigger-demo-toast",
toaster: "toaster-trigger-demo") do %>
Show toast
<% end %>
<template id="trigger-demo-toast">
<%= poetry_toast(variant: :success, duration: 4000) do |toast| %>
<% toast.with_title { "Stamped into the region" } %>
<% toast.with_description { "No server round-trip involved." } %>
<% end %>
</template>
<%= poetry_toaster(id: "toaster-trigger-demo") %>
</div>
API
Poetry::Ui::ToastTrigger::Component — options are
constructor keywords (the poetry_* helper forwards them);
slots are composed inside the block. Generated from the gem's source documentation.
| Option | Type | Details | Description |
|---|---|---|---|
| size: | Symbol | defaults to :default |
The Button size the trigger renders at. |
| template: | String | required | The id of the <template> element holding the rendered toast to stamp. |
| toaster: | String | Scopes the stamp to one toaster region id on multi-toaster pages; omit for the page's toaster. | |
| variant: | Symbol | defaults to :outline |
The Button variant the trigger renders at. |
Styling
Every part carries a stable data-slot attribute — target
[data-slot=…] from your own CSS to restyle it. State rides
data attributes on the parts below. This contract is verified against rendered DOM in CI.
| Part | Description |
|---|---|
| [data-slot=toast-trigger] | The stamping button - press clones the template's toast into the toaster region |
| [data-slot=label] | The Button's label span (the trigger renders AS a poetry Button) |
State attributes
| Part | Attribute | Condition | Values |
|---|---|---|---|
| toast-trigger | data-variant | always - the Button variant the trigger renders at | — |
| toast-trigger | data-size | always - the Button size the trigger renders at | — |
Wiring
The Stimulus surface each element carries — declared in the component, verified against rendered DOM in CI. Bare actions fire on the element's default event.
| Element | Controller | Wiring |
|---|---|---|
| root | poetry--core--toast-trigger | registers · value template · value toaster (if) · fire on click |