Usage
<%= form_with url: root_path do |f| %>
<%= f.text_area :bio %>
<%= f.text_area :comment, rows: 5 %>
<% end %>Props
| Prop | Type | Default | Description |
|---|---|---|---|
rows | Integer | 3 | Number of visible text lines. |
label | String | false | humanized attribute name | Custom label text. Set to `false` to hide the label. |
hint | String | nil | Helper text displayed below the field. |
error | String | nil | Manual error message. ActiveRecord errors are displayed automatically. |
disabled | Boolean | false | Disable the field. |
Also accepts any HTML attributes via **options (e.g., id:, data:, aria:). class: is also supported for custom styling.
Examples
Basic Text Area
<%= form_with url: root_path do |f| %>
<%= f.text_area :bio %>
<%= f.text_area :comment, placeholder: "5 rows by default", rows: 5 %>
<% end %>Label customization
<%= form_with url: root_path do |f| %>
<%= f.text_area :custom_label, label: "Custom Label Text" %>
<%= f.text_area :no_label, label: false, placeholder: "Field without label" %>
<% end %>Hint message
<%= form_with url: root_path do |f| %>
<%= f.text_area :bio, hint: "Max 500 characters" %>
<% end %>Disabled State
<%= form_with url: root_path do |f| %>
<%= f.text_area :disabled_field, value: "This text area is disabled", disabled: true %>
<% end %>Validation
<% user = User.new %>
<% user.errors.add(:bio, "is required") %>
<%= form_with model: user, url: root_path do |f| %>
<%= f.text_area :bio, label: "Active Record Validations" %>
<%= f.text_area :manual_error_field, error: "This field has a custom error", value: "Invalid Value" %>
<% end %>