Class: Shadcn::TextareaComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/shadcn/textarea_component.rb

Overview

Textarea component for multi-line text input Matches shadcn/ui Textarea component

Examples:

Basic textarea

<%= render Shadcn::TextareaComponent.new(name: "bio", placeholder: "Tell us about yourself") %>

With rows

<%= render Shadcn::TextareaComponent.new(name: "message", rows: 6) %>

Constant Summary collapse

BASE_CLASSES =
"flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"

Instance Attribute Summary

Attributes inherited from BaseComponent

#class_name, #data, #html_options

Instance Method Summary collapse

Methods inherited from BaseComponent

#content

Methods included from Rails::Helpers::ClassNameHelper

#cn

Constructor Details

#initialize(name: nil, id: nil, value: nil, placeholder: nil, rows: 3, cols: nil, disabled: false, required: false, readonly: false, autofocus: false, minlength: nil, maxlength: nil, **options) ⇒ TextareaComponent

Returns a new instance of TextareaComponent.

Parameters:

  • name (String, nil) (defaults to: nil)

    Textarea name attribute

  • id (String, nil) (defaults to: nil)

    Textarea id attribute

  • value (String, nil) (defaults to: nil)

    Initial value

  • placeholder (String, nil) (defaults to: nil)

    Placeholder text

  • rows (Integer) (defaults to: 3)

    Number of visible rows

  • cols (Integer, nil) (defaults to: nil)

    Number of visible columns

  • disabled (Boolean) (defaults to: false)

    Whether textarea is disabled

  • required (Boolean) (defaults to: false)

    Whether textarea is required

  • readonly (Boolean) (defaults to: false)

    Whether textarea is readonly

  • autofocus (Boolean) (defaults to: false)

    Whether to autofocus

  • minlength (Integer, nil) (defaults to: nil)

    Minimum length

  • maxlength (Integer, nil) (defaults to: nil)

    Maximum length



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/components/shadcn/textarea_component.rb', line 28

def initialize(
  name: nil,
  id: nil,
  value: nil,
  placeholder: nil,
  rows: 3,
  cols: nil,
  disabled: false,
  required: false,
  readonly: false,
  autofocus: false,
  minlength: nil,
  maxlength: nil,
  **options
)
  super(**options)
  @name = name
  @id = id
  @value = value
  @placeholder = placeholder
  @rows = rows
  @cols = cols
  @disabled = disabled
  @required = required
  @readonly = readonly
  @autofocus = autofocus
  @minlength = minlength
  @maxlength = maxlength
end