Forms

Text area

A labelled multi-line input that the user can resize vertically.

JxTextArea import 'package:jx_cli/ui.dart' Available since 0.0.2

Preview

Up to 280 characters.

When to use it

  • Messages, descriptions, feedback.

States

Write at least 20 characters.

Error
Disabled

Minimal example

Dart
JxTextArea(id: 'message', label: 'Message')

Complete example

A full Jaspr component you can paste into a project.

Dart
import 'package:jaspr/jaspr.dart';
import 'package:jx_cli/ui.dart';

/// Bio with a live character count in the hint.
class BioField extends StatefulComponent {
  const BioField({super.key});

  @override
  State<BioField> createState() => _BioFieldState();
}

class _BioFieldState extends State<BioField> {
  static const max = 280;
  String bio = '';

  @override
  Component build(BuildContext context) {
    final left = max - bio.length;
    return JxTextArea(
      id: 'bio',
      label: 'Bio',
      rows: 5,
      value: bio,
      hint: '$left characters left.',
      error: left < 0 ? 'Shorten your bio by ${-left} characters.' : null,
      onInput: (value) => setState(() => bio = value),
    );
  }
}

Properties

Property Type Default Description
id String required Links the label and the message.
label String required Visible label.
rows int 4 Initial height, in lines.
name String? null Form field name.
value String? null Current text.
placeholder String? null Example text.
hint String? null Help text under the field.
error String? null Marks the field invalid and replaces the hint.
required bool false Native required .
disabled bool false Disables the field.
classes String? null Extra JX classes, appended after the component classes.

Events

Callback Type Fires when
onInput ValueChanged<String>? Every change, with the new text.

Customizing

  • Pass classes to add or override utilities: they come last, so classes: 'w:full' wins over the default width.
  • Resizing is vertical (rsz:y); the minimum height is 96 px.

Accessibility

  • Same wiring as the text field: label for, aria-describedby, aria-invalid.