Checkbox

Check it out! Ha haaa.. ha.
Includes a Ruby component and corresponding Rails helper
Ruby

Example

<%= nk_checkbox %>

API tries to match Rails' own checkbox() helper.

Form use

To use in forms, it's easiest to use the Form Builder.

f.checkbox tries to match Rails' own API.

For extra convenience use the f.field method.

At least for a little bit
<%= nk_form_with model: @session do |f| %>
  <%= f.field :remember_me,
    as: :checkbox,
    label: "Remember me",
    description: "At least for a little bit" %>
<% end %>

With a label

To add a label, use the label: argument.

<%= nk_checkbox label: "Accept your fate" %>

Checkbox group

Display multiple related checkboxes in a group under the same title.

<%= nk_checkbox_group do |g| %>
  <%= g.title "Choose your poison" %>
  <%= g.item value: :coke, label: "Coke", checked: true %>
  <%= g.item value: :zero, label: "Coke Zero" %>
<% end %>

Usage

NB: Using through FormBuilder#field is recommended. See Field docs.

nk_checkbox(
  compat_object_name = nil,
  compat_method = nil,
  compat_options = {},
  compat_checked_value = "1",
  compat_unchecked_value = "0",
  label: nil,
  **attrs
)
PropertyDefaultDescription
compat_object_namenil API compatibility Relevant object
compat_methodnil API compatibility Object attribute
compat_options{} API compatibility Options for checkbox
compat_checked_value"1" API compatibility Value when checked
compat_unchecked_value"0" API compatibility Value when unchecked
labelnil Text label for checkbox
**attrsHTML attributes for <input> element