Switch
The switch' fancy cousin
Includes a Ruby component and corresponding Rails helper
RubyIncludes a Stimulus controller
StimulusExample
<%= nk_switch %>Form use
To use in forms, it's easiest to use the Form Builder.
f.switch tries to match Rails' own API.
For extra convenience use the f.field method.
<%= nk_form_with model: @session do |f| %>
<%= f.field :remember_me,
as: :switch,
label: "Remember me",
description: "At least for a little bit" %>
<% end %>With a label
To add a label, use the label: argument.
<%= nk_switch label: "Accept your fate" %>Sizes
:sm
:md
Usage
| ||
|---|---|---|
| Property | Default | Description |
size | :md | One of :sm / :md |
**attrs | HTML attributes for <button> element | |