Skip to content
Browse documentation

Textarea

A multi-line input in the Input's frame, as TextBox with AcceptsReturn.

ExampleInteractive
Textarea — Avalonia UIKit
Live demo unavailable
<TextBox AcceptsReturn="True" MinLines="3" MaxLines="3" PlaceholderText="Write a message"
         Width="280" HorizontalAlignment="Left" />

Usage

TextBox AcceptsReturn="True" is the textarea. It has no fixed height: give it rows with MinLines and MaxLines, or a Height. The theme wraps the text (TextWrapping="Wrap"), aligns it to the top and pads it inside the scrolling area rather than the frame, so the overlay scrollbar runs along the whole inner frame. The frame, the placeholder, the focus ring, the disabled look and the right-click menu are the Input's. Sizes: xsmall, small, large (medium is the default).

uikit:Inputs.TabSize (2 is the usual size) makes Tab indent: at the caret, or every selected line. Shift+Tab outdents the caret's or the selected lines, and Cmd+] and Cmd+[ (Ctrl+] and Ctrl+[ on Windows and Linux) indent and outdent the lines. uikit:Inputs.HardTabs="True" indents with a tab character instead of spaces. A read-only textarea, or one without a TabSize, leaves Tab to move the focus.

Examples

MinLines="2" MaxLines="5": the field grows with its text from two to five lines, then scrolls.

Auto growInteractive
Live demo unavailable
<StackPanel Spacing="12" Width="280" HorizontalAlignment="Left">
  <TextBox AcceptsReturn="True" MinLines="2" MaxLines="5" Text="One" />
  <TextBox AcceptsReturn="True" MinLines="2" MaxLines="5" Text="One&#10;Two&#10;Three&#10;Four" />
</StackPanel>

The four sizes, each two lines tall.

SizesInteractive
Live demo unavailable
<StackPanel Spacing="12" Width="280" HorizontalAlignment="Left">
  <TextBox Classes="xsmall" AcceptsReturn="True" MinLines="2" MaxLines="2" PlaceholderText="Extra small" />
  <TextBox Classes="small" AcceptsReturn="True" MinLines="2" MaxLines="2" PlaceholderText="Small" />
  <TextBox AcceptsReturn="True" MinLines="2" MaxLines="2" PlaceholderText="Medium" />
  <TextBox Classes="large" AcceptsReturn="True" MinLines="2" MaxLines="2" PlaceholderText="Large" />
</StackPanel>

Read-only and disabled textareas.

StatesInteractive
Live demo unavailable
<StackPanel Spacing="12" Width="280" HorizontalAlignment="Left">
  <TextBox AcceptsReturn="True" MinLines="3" MaxLines="3" Text="Read only&#10;notes" IsReadOnly="True" />
  <TextBox AcceptsReturn="True" MinLines="3" MaxLines="3" Text="Disabled" IsEnabled="False" />
</StackPanel>

Select lines and press Tab or Shift+Tab.

IndentInteractive
Live demo unavailable
<TextBox AcceptsReturn="True" MinLines="4" MaxLines="4" Width="320" HorizontalAlignment="Left"
         uikit:Inputs.TabSize="2"
         Text="Select these lines&#10;and press Tab to indent them,&#10;Shift+Tab to outdent." />