Forms

Text Area

A multi-line text input.

Rust
1use herogpui::components::textarea::TextArea;

Usage

Platform edits support composed text and paste. Enter confirms active composition before inserting a newline.

Rust
1use herogpui::prelude::TextArea;
2use gpui::prelude::*;
3use gpui::px;
4
5gpui::div()
6    .w(px(384.))
7    .child(TextArea::new(self.demo_text("ta-usage", "", cx))
8            .placeholder("Share a quick project update...")
9            .cols(48)
10            .rows(6)
11            .full_width())

Live HeroGPUI compiled to WebAssembly. Select any example without loading another WASM instance.

Anatomy

Rust types

TextArea

Text Area is assembled from these builders. The API reference lists each one.

Customization

Appearance builders and theme tokens Text Area uses.

Styling

Text Area styling
StyleDescription
inner Input px(px(12.)) + FIELD_TEXT + field_radius + apply_field_chrome12px inline inset, 14px desktop type, field radius, colours and shadow match.
inner Input wrapper textLabels use 14px/20px and helper/error text use 12px/16px, independent of host leading.
rows_height(3) = 76pxThe documented three-row default uses three 20px lines plus 16px vertical padding.
apply_field_chromeTheme field border width and colour chain.
direct apply_field_chrome state coloursState colours switch directly; GPUI has no property-transition implementation for these values.
FieldVariant::Secondary in apply_field_chromeLower-emphasis surface treatment.
full_width()Full-width modifier.

API reference

Builders

Text Area builders
BuilderTypeDefaultDescription
rows(u32)u323Sets the visible height from the requested line count and field padding.
cols(u32)u32GPUI has no ch unit, so columns use an 8px character-advance approximation.
value(text, cx)text, cxWrites the caller-provided controlled value into the owned InputState.
default_value(text)textSeeds the uncontrolled InputState once.
on_change(callback)Fn(event: change event) -> ()Reports accepted text and newline edits without reporting rejected maxLength edits.
placeholder(text)textPlaceholder shown while empty and unfocused.
is_disabled(bool)boolfalseRemoves focus and editing and applies disabled opacity.
is_read_only(bool)boolfalseKeeps focus and selection while suppressing edits.
is_required(bool)boolfalseParticipates in the HeroGPUI form validity registry.
name(text)textSubmission name stored with the current multi-line value.
max_length(usize)usizeRejects character and newline edits beyond the limit without reporting an unchanged value.
min_length(usize)usizeMarks a non-empty value invalid below the character minimum.
full_width()boolfalseStretches to the available container width.
variant(FieldVariant)FieldVariantFieldVariant::PrimaryPrimary field chrome or the lower-emphasis surface variant.

Parts

Text Area parts
PartDescription
TextAreaMulti-line editable field backed by InputState with caret, selection and validation.

States

Text Area states
BuilderStateDescription
inner Input hover + apply_field_chromeHoverChanges field background and border while unfocused.
inner Input focus + apply_field_chromeFocusedDraws focused field background, border and ring.
focused field treatmentFocus visiblePinned CSS adds no rule beyond the focused field treatment.
inner Input validity + apply_field_chromeInvalidUses invalid field ring and focused background.
is_disabled(bool)DisabledApplies theme disabled opacity and removes editing and focus.