Button
What happens if I press this huge red one labeled "Don't touch!"
Includes a Ruby component and corresponding Rails helper
RubyVariants
Nitro Kit gives you 4 variants by default. Most buttons in your app should just be buttons. Every page should preferably not have more than one primary button.
nk_button
nk_primary_button
nk_destructive_button
nk_ghost_button
Sizes
:xs
:sm
:md
With icons
<%= nk_button(icon: "fuel") %>
<%= nk_button("Text and icon", icon: "caravan") %>
<%= nk_button("Icon right", icon_right: "car") %>
Button groups
<%= nk_button_group do %>
<%= nk_button("Button") %>
<%= nk_button("Button") %>
<%= nk_primary_button("Button") %>
<% end %>
API compatibility
<%= nk_button_link_to "Go home", root_path %>
<%= nk_destructive_button_to "Delete post", posts_path,
method: :delete, data: { turbo_frame: "test-result" } %>
Usage
| ||
---|---|---|
Property | Default | Description |
text | nil | Plain text content |
href | nil |
If truthy, the button will be an a element. Otherwise it's button .
|
variant | :default | One of :default / :primary / :destructive / :ghost |
size | :md | One of :xs / :sm / :md |
icon | nil | Left side icon. See Icon docs. |
icon_right | nil | Right side icon. See Icon docs. |
**attrs | HTML attributes for <button> element |
| ||
---|---|---|
Property | Default | Description |
**attrs | HTML attributes for <div> element |