Class: Shadcn::CheckboxComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- Shadcn::CheckboxComponent
- Defined in:
- app/components/shadcn/checkbox_component.rb
Overview
Checkbox component using native Styled with CSS to match shadcn/ui design Works without JavaScript
Constant Summary collapse
- BASE_CLASSES =
[ "shadcn-checkbox", "peer h-4 w-4 shrink-0 rounded-sm border border-primary", "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1", "disabled:cursor-not-allowed disabled:opacity-50", "cursor-pointer" ].join(" ")
Instance Attribute Summary
Attributes inherited from BaseComponent
#class_name, #data, #html_options
Instance Method Summary collapse
-
#initialize(name: nil, id: nil, value: "1", checked: false, disabled: false, required: false, **options) ⇒ CheckboxComponent
constructor
A new instance of CheckboxComponent.
Methods inherited from BaseComponent
Methods included from Rails::Helpers::ClassNameHelper
Constructor Details
#initialize(name: nil, id: nil, value: "1", checked: false, disabled: false, required: false, **options) ⇒ CheckboxComponent
Returns a new instance of CheckboxComponent.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/components/shadcn/checkbox_component.rb', line 36 def initialize( name: nil, id: nil, value: "1", checked: false, disabled: false, required: false, ** ) super(**) @name = name @id = id || (name ? "checkbox-#{name}" : nil) @value = value @checked = checked @disabled = disabled @required = required end |