Radio Button
A control that allows users to make a single selection from a list of options.
Usage
Example
Checked
Installation
Components
Component | Built using | Source |
---|---|---|
RadioButton | Phlex |
A control that allows users to make a single selection from a list of options.
div(class: "flex items-center space-x-2") do RadioButton(id: "default") FormFieldLabel(for: "default") { "Default" } end
div(class: "flex items-center space-x-2") do RadioButton(id: "checked", checked: true) FormFieldLabel(for: "checked") { "Checked" } end
Run the install command
rails g ruby_ui:component RadioButton
1
Add RubyUI::RadioButton
to app/components/ruby_ui/radio_button.rb
# frozen_string_literal: true module RubyUI class RadioButton < Base def view_template input(**attrs) end private def default_attrs { type: "radio", data: { ruby_ui__form_field_target: "input", action: "change->ruby-ui--form-field#onInput invalid->ruby-ui--form-field#onInvalid" }, class: "h-4 w-4 p-0 border-primary rounded-full flex-none" } end end end
Component | Built using | Source |
---|---|---|
RadioButton | Phlex |