Toast
Brief feedback after an action.
Usage
After the one-time setup, call the helper directly from ERB. No component import is needed.
<%= lc_toast "Project saved.", timeout: 0 %>
Examples
Brief feedback
<%= lc_toast "Project saved.", timeout: 0 %>
Over dialogs and sticky headers
<%# In an app, render the region once in the layout and append toasts with turbo_stream.append. %>
<%= lc_toast_region id: "example-1-toasts" %>
<template id="example-1-toast"><%= lc_toast "Project saved." %></template>
<%= lc_button "Save project", data: { controller: "toast-demo", action: "toast-demo#show", toast_demo_template_value: "example-1-toast", toast_demo_region_value: "example-1-toasts" } %>
Centred, at the top on phones
<%# Centred at the bottom, and at the top on phones, clear of a bottom tab bar. %>
<%= lc_toast_region id: "example-2-toasts", placement: :bottom_center, mobile_placement: :top_center %>
<template id="example-2-toast"><%= lc_toast "Expense added." %></template>
<%= lc_button "Add expense", data: { controller: "toast-demo", action: "toast-demo#show", toast_demo_template_value: "example-2-toast", toast_demo_region_value: "example-2-toasts" } %>
API reference
Helpers render semantic HTML and include their interaction wiring. Pass native attributes through class:, data:, aria: and the usual Rails options. Blocks use captured ERB content.
lc_toast
lc_toast(message = nil, tone: :success, timeout: 4000, **attributes, &block)
| Input | Default | Values |
|---|---|---|
| message | nil | — |
| tone | :success | :neutral · :primary · :success · :warning · :destructive |
| timeout | 4000 | — |
| attributes | {} | Native HTML attributes; class:, data: and aria: merge with defaults |
| block | Captured block | Captured Rails ERB content |
lc_toast_region
lc_toast_region(placement: :bottom_end, mobile_placement: nil, **attributes, &block)
| Input | Default | Values |
|---|---|---|
| placement | :bottom_end | — |
| mobile_placement | nil | — |
| attributes | {} | Native HTML attributes; class:, data: and aria: merge with defaults |
| block | Captured block | Captured Rails ERB content |
The examples also use lc_button. Each is documented on its own page.
Styling and extension
Use class: to merge utilities, native attributes for application behavior, and the theming guide for the shared palette. For custom markup, the advanced class helpers expose the same styles, including glass surfaces and class merging.