Class: Flowbite::Input::RadioButton
- Defined in:
- app/components/flowbite/input/radio_button.rb
Overview
The radio button component can be used to allow the user to choose a single option from one or more available options.
Constant Summary
Constants inherited from Field
Instance Attribute Summary
Attributes inherited from Field
Class Method Summary collapse
-
.sizes ⇒ Object
Radio buttons only have their default size.
-
.styles ⇒ Object
rubocop:disable Layout/LineLength.
Instance Method Summary collapse
-
#call ⇒ Object
Returns the HTML to use for the actual input field element.
-
#initialize(attribute:, form:, value:, disabled: false, options: {}) ⇒ RadioButton
constructor
A new instance of RadioButton.
- #input_field_type ⇒ Object
Methods inherited from Field
Constructor Details
#initialize(attribute:, form:, value:, disabled: false, options: {}) ⇒ RadioButton
Returns a new instance of RadioButton.
40 41 42 43 |
# File 'app/components/flowbite/input/radio_button.rb', line 40 def initialize(attribute:, form:, value:, disabled: false, options: {}) super(attribute: attribute, disabled: disabled, form: form, options: ) @value = value end |
Class Method Details
.sizes ⇒ Object
Radio buttons only have their default size.
12 13 14 15 16 |
# File 'app/components/flowbite/input/radio_button.rb', line 12 def sizes { default: ["w-4", "h-4"] } end |
.styles ⇒ Object
rubocop:disable Layout/LineLength
19 20 21 22 23 24 25 26 27 |
# File 'app/components/flowbite/input/radio_button.rb', line 19 def styles { default: Flowbite::Style.new( default: ["text-blue-600", "bg-gray-100", "border-gray-300", "focus:ring-blue-500", "dark:focus:ring-blue-600", "dark:ring-offset-gray-800", "focus:ring-2", "dark:bg-gray-700", "dark:border-gray-600"], disabled: ["text-blue-600", "bg-gray-100", "border-gray-300", "focus:ring-blue-500", "dark:focus:ring-blue-600", "dark:ring-offset-gray-800", "focus:ring-2", "dark:bg-gray-700", "dark:border-gray-600"], error: ["text-red-600", "bg-red-50", "border-red-500", "focus:ring-red-500", "dark:focus:ring-red-600", "dark:ring-offset-gray-800", "focus:ring-2", "dark:bg-gray-700", "dark:border-red-500"] ) }.freeze end |
Instance Method Details
#call ⇒ Object
Returns the HTML to use for the actual input field element.
31 32 33 34 35 36 37 38 |
# File 'app/components/flowbite/input/radio_button.rb', line 31 def call @form.send( input_field_type, @attribute, @value, ** ) end |
#input_field_type ⇒ Object
45 46 47 |
# File 'app/components/flowbite/input/radio_button.rb', line 45 def input_field_type :radio_button end |