Class: Shadcn::ToggleComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- Shadcn::ToggleComponent
- Defined in:
- app/components/shadcn/toggle_component.rb
Overview
Toggle component for a two-state button Matches shadcn/ui Toggle component
Constant Summary collapse
- VARIANTS =
{ default: "bg-transparent", outline: "border border-input bg-transparent shadow-sm hover:bg-accent hover:text-accent-foreground" }.freeze
- SIZES =
{ sm: "h-8 px-2", default: "h-9 px-3", lg: "h-10 px-3" }.freeze
- BASE_CLASSES =
"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground"
Instance Attribute Summary
Attributes inherited from BaseComponent
#class_name, #data, #html_options
Instance Method Summary collapse
-
#initialize(variant: :default, size: :default, pressed: false, disabled: false, aria_label: nil, **options) ⇒ ToggleComponent
constructor
A new instance of ToggleComponent.
Methods inherited from BaseComponent
Methods included from Rails::Helpers::ClassNameHelper
Constructor Details
#initialize(variant: :default, size: :default, pressed: false, disabled: false, aria_label: nil, **options) ⇒ ToggleComponent
Returns a new instance of ToggleComponent.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/components/shadcn/toggle_component.rb', line 36 def initialize( variant: :default, size: :default, pressed: false, disabled: false, aria_label: nil, ** ) super(**) @variant = variant @size = size @pressed = pressed @disabled = disabled @aria_label = aria_label end |