Textarea
Displays a textarea field.
Usage
Textarea
div(class: "grid w-full max-w-sm items-center gap-1.5") do Textarea(placeholder: "Textarea") end
Copied!
Copy failed!
Disabled
div(class: "grid w-full max-w-sm items-center gap-1.5") do Textarea(disabled: true, placeholder: "Disabled") end
Copied!
Copy failed!
With formfield
This is a textarea
div(class: "grid w-full max-w-sm items-center gap-1.5") do FormField do FormFieldLabel(for: "textarea") { "Textarea" } FormFieldHint { "This is a textarea" } Textarea(placeholder: "Textarea", id: "textarea") FormFieldError() end end
Copied!
Copy failed!
Installation
Using RubyUI CLI
Run the install command
rails g ruby_ui:component Textarea
Copied!
Copy failed!
Manual installation
1
Add RubyUI::Textarea
to app/components/ruby_ui/textarea.rb
# frozen_string_literal: true module RubyUI class Textarea < Base def initialize(rows: 4, **attrs) @rows = rows super(**attrs) end def view_template(&) textarea(rows: @rows, **attrs, &) end private def default_attrs { data: { ruby_ui__form_field_target: "input", action: "input->ruby-ui--form-field#onInput invalid->ruby-ui--form-field#onInvalid" }, class: "flex w-full rounded-md border bg-background px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50 border-border focus-visible:ring-ring placeholder:text-muted-foreground" } end end end
Copied!
Copy failed!
Components
Component | Built using | Source |
---|---|---|
Textarea | Phlex |