Select

Sort of a button for picking a single value
Includes a Ruby component and corresponding Rails helper
Ruby

Example

<%= nk_select "journey", "direction", %w[North East South West], value: "South" %>

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

Install

Set up Nitro Kit then

bin/rails generate nitro_kit:add select

Form use

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

f.select tries to match Rails' own API.

For extra convenience use the f.field method.

Who's foot is on the pedal?
<%= nk_form_for :race do |f| %>
  <%= f.field :driver,
          options: %w[David Tobi],
          value: "David",
          as: :select,
          label: "Driver",
          description: "Who's foot is on the pedal?" %>
<% end %>

Usage

NB: While select supports Rails' API, using f.field is recommended.

nk_select(
  compat_object_name = nil,
  compat_method = nil,
  options = nil,
  compat_options = {},
  label: nil,
  include_blank: false,
  prompt: nil,
  index: nil,
  **attrs
)
PropertyDefaultDescription
compat_object_namenil API compatibility Relevant object
compat_methodnil API compatibility Object attribute
optionsnil List of [label, value] pairs
compat_options{} API compatibility "Options" as a hash
include_blankfalse Whether to include a blank option
promptnil Label for blank option