Checkbox Edit

A control that allows the user to toggle between checked and not checked.

Examples

Installation


  rails generate shadcn-ui checkbox

Usage

<%= render_checkbox(label:, name:) %>

The Checkbox component introduces:

  • app/helpers/components/checkbox_helper.rb
  • app/views/components/ui/_checkbox.html.erb
  • app/javascript/controllers/ui/checkbox_controller.js

render_checkbox accepts two required arguments, one for the name: of the checkbox which will pair with label: of the checkbox. The toggle functionality is controller by app/javascript/controllers/ui/checkbox_controller.js.