Sonner
Temporary notifications stacked in a polite live region. Fire them with window.toast or through Stimulus.
Installation
Shadwire follows shadcn/ui's open code model: the component's source is copied into your application and becomes yours. Install it with the CLI:
The sonner registry item installs these files:
-
app/components/ui_component.rb -
app/components/ui/sonner_component.rb -
app/helpers/ui/sonner_helper.rb -
app/javascript/controllers/ui_sonner_controller.js -
vendor/shadwire/shadwire.css
This component uses Stimulus, so the application needs importmap-rails and stimulus-rails with automatic controller loading.
Haven't installed the CLI yet? gem install shadwire, then shadwire init.
Usage
Examples
Default
The default, success, error and with-action variants.
API reference
Every part accepts class / class_name and **attrs.
| Component | Argument | Default | Description |
|---|---|---|---|
Sonner |
position |
:bottom_right |
Where toasts stack: :top_left, :top_center, :top_right, :bottom_left, :bottom_center or :bottom_right. |
Sonner |
duration |
4000 |
Milliseconds a toast stays before it dismisses itself. |