Toggler

Toggle switch component that enhances the standard Rails check_box with improved styling.

Usage

<%= form_with url: root_path do |f| %>
  <%= f.toggler :push_notifications %>
  <%= f.toggler :notifications, hint: "Enable notifications" %>
<% end %>
Props
PropTypeDefaultDescription
labelString | falsehumanized attribute nameCustom label text. Set to `false` to hide the label.
hintStringnilHelper text displayed below the toggler.

Also accepts any HTML attributes via **options (e.g., id:, data:, aria:). class: is also supported for custom styling.

Examples

Basic Toggler

Here you can have a hint

<%= form_with url: root_path do |f| %>
  <%= f.group do %>
    <%= f.toggler :basic_push_notifications %>
  <% end %>

  <%= f.group do %>
    <%= f.toggler :basic_notifications, hint: "Here you can have a hint" %>
  <% end %>
<% end %>