Class: Shadcn::ButtonComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- Shadcn::ButtonComponent
- Defined in:
- app/components/shadcn/button_component.rb
Overview
Button component with multiple variants and sizes Matches shadcn/ui Button component
Constant Summary collapse
- VARIANTS =
Available button variants
{ default: "bg-primary text-primary-foreground shadow-xs hover:bg-primary/90", destructive: "bg-destructive text-destructive-foreground shadow-xs hover:bg-destructive/90", outline: "border border-input bg-background shadow-xs hover:bg-accent hover:text-accent-foreground", secondary: "bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80", ghost: "hover:bg-accent hover:text-accent-foreground", link: "text-primary underline-offset-4 hover:underline" }.freeze
- SIZES =
Available button sizes
{ default: "h-9 px-4 py-2", sm: "h-8 rounded-md px-3 text-xs", lg: "h-10 rounded-md px-8", icon: "h-9 w-9", icon_sm: "h-8 w-8", icon_lg: "h-10 w-10" }.freeze
- BASE_CLASSES =
Base classes applied to all buttons
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0"
Instance Attribute Summary
Attributes inherited from BaseComponent
#class_name, #data, #html_options
Instance Method Summary collapse
-
#initialize(variant: :default, size: :default, href: nil, type: "button", disabled: false, loading: false, **options) ⇒ ButtonComponent
constructor
A new instance of ButtonComponent.
Methods inherited from BaseComponent
Methods included from Rails::Helpers::ClassNameHelper
Constructor Details
#initialize(variant: :default, size: :default, href: nil, type: "button", disabled: false, loading: false, **options) ⇒ ButtonComponent
Returns a new instance of ButtonComponent.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'app/components/shadcn/button_component.rb', line 60 def initialize( variant: :default, size: :default, href: nil, type: "button", disabled: false, loading: false, ** ) super(**) @variant = variant.to_sym @size = size.to_sym @href = href @type = type @disabled = disabled @loading = loading end |