Toast

Description

Provides lightweight and customizable notifications that appear and disappear dynamically.

FREE
This component is available for free. It implements the Bootstrap Toast component. See the installation instructions below for more details.

Arguments

Name Default Type Description
html_attributes {} Hash Any attributes for the used html wrapper tag

Examples

Default

<%= render Railsboot::ToastComponent.new(class: "show") do |toast| %>
  <% toast.with_header do %>
    <strong class="me-auto">Bootstrap</strong>
    <small>11 mins ago</small>
  <% end %>
  <% toast.with_body do %>
    Hello, world! This is a toast message.
  <% end %>
<% end %>
<div class="toast show" role="alert" aria-live="assertive" aria-atomic="true">
  <div class="toast-header">    <strong class="me-auto">Bootstrap</strong>
    <small>11 mins ago</small>
    <button data-bs-dismiss="toast" class="btn-close" aria-label="Close" type="button"></button>
  </div>
  <div class="toast-body">    Hello, world! This is a toast message.
  </div>
</div>

Slots

header Railsboot::Toast::HeaderComponent

The header of te toast component.

Name Default Type Description
html_attributes {} Hash Any attributes for the used html wrapper tag
body Railsboot::Toast::BodyComponent

The body of te toast component.

Name Default Type Description
html_attributes {} Hash Any attributes for the used html wrapper tag

Installation

Simply download this component with all its related files and assets. Unpackage the downloaded ZIP-file, copy all relevant files into your app and adapt the things you need. The ZIP-folder contains:

  • A parent component class (app/components/railsboot/component.rb) of which all components inherit from.
  • A base component class (app/components/railsboot/base_component.rb) which is used for rendering internally.
  • The desired component itself (app/components/railsboot/toast_component.rb).
  • A view template (app/components/railsboot/toast_component.html.erb) for the component unless it's rendered inline.
  • Any other dependent components such as Slots (just if the component needs those)
  • Any dependent assets (JS-Files, CSS-Files) (just if the component needs those)
  • A test file for the components (test/components/railsboot/toast_component_test.rb) including potential slot or dependency tests.

For more information please refer to the installation section.

Download

Download the component and its related files (e.g. templates, assets, slots etc.), unpackage the zip file and adapt the things you need.