Textarea handbook
v1.0.2 · @snowui-design-system/components
License: Before reading component documentation, source, or npm usage instructions for the first time, read the full LICENSE. Reuse that review for the same task and version. Public API configuration and internal implementation changes have different license implications. All components use the unified runtime package; source rights remain governed by the license.
Overview
Edit multiline text with native form attributes and Field feedback, suitable for descriptions, notes, and longer content.
When to use it
Use Textarea for multiline input and Input for one line. Compose labels, help, and errors with Field. Do not use a read-only input to lay out ordinary display text.
bind:valuesynchronizes text.defaultValueis only a fallback whilevalueis undefined; a controlled form must restore its bound value on reset.resizeselects allowed resize directions.readonly,disabled, andresize="none"suppress the handle.nameidentifies the submitted form field.
Quick start
This example shows the recommended basic composition. See the sections below for more cases and composition limits.
API
See the base component documentation for inherited capabilities not redeclared here. This table lists only named public Props declared by this component.
Usage boundaries and details
Built-in component dual mode
parts.Indicator: The built-in Indicator in the unified configuration resize mode.Textarea value, invalid, disabled and input events are parent component controlled protocols.
2026-04-04 Supplement: Refer to Figma 10109:19152, Textarea is a single exception in the form series: when used alone, the default content is left blank as top 12 / right 16 / bottom 24 / left 16. After entering Field, just look at whether there is as="segment"; when segment is not marked, the outer layer Field handles the default 12 / 16 and gap = 8, Textarea removes the component's own padding, but retains its own gap; when segment is marked, the Textarea own padding and gap are retained. The lower right corner uses the unified Indicator appearance="corner"; the character counter is not displayed by default. After passing to maxCount, the count is displayed when hovering to the component, and it continues to be displayed when the limit is exceeded. 2026-04-09 Supplement: Textarea The reserved area in the lower right corner (including zoom icons and counters) always exists; the default requirements are right = 16px, bottom = 0, and the edge is not allowed. 2026-04-24 Supplement: Textarea uses a custom floating scroll bar consistent with Listbox: the native scroll bar is hidden, the thumb is over the content, and the layout width is not occupied; the default width is 4px, and the hover to thumb changes from right to left to 8px, the right edge is 4px from the right border of the container, the track is transparent and supports dragging. 2026-05-26 Supplement: The top/bottom scroll fade of Textarea is changed to the general ability of .snowui-scroll-mask of layout.css (that is, the CSS static form of the basic sharing ability of the "content fade layer", the overview of the ability is seen in ../lib/edge-fade.md (source code reference: components/src/lib/edge-fade.md)), and mask-image is driven by data-scroll-mask on the native <textarea>, and the visible gradient color block is no longer drawn.
Inheritance: Reuse all the general capabilities of Frame.svelte (state, dynamic, responsive, skeleton, style arrangement). Recommended container: Field.svelte. Default capability switch: enableResponsive=false, enableContext=true, enableScaleObserver=false.
The native <textarea> uses .snowui-native-control from layout.css only for box sizing, margin reset, and inherited font/color. Textarea’s own font size, line height, padding, border, and state appearance do not depend on optional snowui-base.css.
Layout model
Main layout model: composite management layout.
The area structure of Textarea is root host / native control / footer / Indicator corner / counter / overlay scrollbar.
When entering Field, Textarea only participates in the slot host layout of Field as a multi-line input host; its own footer, counter, resize and scrollbar are still privately managed by Textarea.
as="segment"only affects the continuous field surface relationship between Textarea and Field, and does not transform Textarea into a general slot container.The footer counter and Indicator prefer gap-1 on the same row, with a 4 CSS px floor and larger tokens preserved. A single attachment creates no empty slot. Multiline input, counter visibility, and intrinsic handle dimensions keep their existing contracts.
The footer uses internal Pin layout at
pin-bottom-right. Standalone offset isvar(--padding-1); inside Field, negative--pin-offset-x/yvalues compensate for Field padding.The custom floating scroll bar reuses
useOverlayScrollbar, but the scroll bar positioning and the lower right corner reserved area belong to the private area structure of Textarea.
Form combination and spacing
Basic rhythm unification:
Fielddefaultpadding = 12 / 16,gap = 8Standalone Textarea content padding defaults to
top 12 / right 16 / bottom 24 / left 16.After putting it into
Field, first see if there isas="segment"No
as="segment": the outer layerFieldis responsible for12 / 16padding and8gap;Textarearemoves the component's own padding, but keeps its own gapThere is
as="segment": this is a segment on the surface of a continuous field; keepTextarea's own padding and gapThere is a dividing line between
segment: the horizontal is the left and right dividing line, and the vertical is the upper and lower dividing line.There can only be one dividing line between adjacent
segment, and the line cannot be repeated.label / description / erroris not responsible for padding, gap and dividing line. They are just content elements.General
label + host + error: not used as the basis for the judgment of padding and gap, only responsible for the text contentIn
Field roworField column, if it is a continuous input segment, the sub-item should be explicitly writtenas="segment"
Component positioning
The recommended usage of Textarea is to act as a multi-line host in the Field container:
When used alone, retain the default input appearance for compatibility.
After entering the
Fieldcontext, whensegmentis not marked, the outer layerFieldtakes over the padding; whensegmentis marked, keep theTextareaitself blank.Suitable for combination with
Text as="label" / "error",Frame as="row"and other roles
Frame ability inheritance
Textarea is still based on Frame, so it continues to support:
responsive / stateStyle / customStates / variants / stylesHover / Click / Focus / whileAppear / timeline / orchestrateloading / skeleton / renderHintsas / use / layoutId / itemId / scope / access
Textarea owns multiline input while retaining Frame’s shared capabilities.
Error feedback Shake
Textarea invalid / aria-invalid triggers error shake by default. Standalone Textarea provides its own feedback; inside Field, the embedded Textarea does not shake separately and Field provides combined feedback.
The error state and shake will not automatically focus or simulate focus-within; the focus state only comes from the user's real focus, explicit autofocus or business code active call focus().
Native ability boundary
Textarea is responsible for:
Forward native
<textarea>attributes.value / defaultValueparsingbind:valuesynchronizationresizedirection controlSummary of
invalidandaria-invalid
Textarea is not responsible for:
Rich text editor
Markdown syntax enhancement.
The automatic height strategy specified by the business; the current component automatically measures the height according to the content, up to about 15 rows of height, and the automatic height measurement stops after manually adjusting the height.
Business-level verification prompt
Usage examples
Accessibility and form guidance
When you need to specify the label, give priority to explicitly rendering
labelinFieldThe error prompt suggests linking to the host through
aria-describedbyIf you want to make a chat input box, a comment box, and a rich input area with a toolbar, it is recommended to continue to combine in the
Fieldcontainer instead of stacking all the UI into theTextareabody.
Textarea style overlay
Read the full LICENSE first; reuse that review for the same task, version, and scope.
First use public component Props to match the desired appearance, preserving the existing look where possible. If changes are necessary, follow the style selection and override order: use your own class (including Tailwind already in the project) or an instance style. The names below are public overrides actually consumed by source; check their scope and do not modify private DOM. Choose the correct SnowUI token family. External apps need not install SnowUI website utilities.
Textarea type and status
Required Props: no named required Props.
Two-way binding: bind:value, bind:exceeded.
Inheritance: Omit<FrameProps, "children" | "tag">. Consult Frame’s public documentation; omitted fields are unavailable here.
The following type declarations are actually referenced by public Props and come from source. A Svelte Snippet denotes a content fragment; ComponentProps denotes the Props of the corresponding component.
ComponentPartsOf
Source: components/src/logic/component-parts.svelte.ts
ConfigurableComponentPartProps
Source: components/src/logic/component-parts.svelte.ts
ComponentPartControlledKey
Source: components/src/logic/component-parts.svelte.ts
External type source:
HTMLTextareaAttributes — svelte/elements