fossui
Components

Text Field

A text input with label, helper and error captions, icon slots, password mode, and a multiline textarea.

A text field pairs an editable box with an optional label above and a helper or error caption below. Colors, radius, type, and spacing come from the theme, so a global retheme restyles every field. It is single line by default.

import 'package:fossui/fossui.dart';

FossTextField(
  label: 'Email',
  hintText: 'you@example.com',
  onChanged: (value) => setState(() => email = value),
);

Label and helper

label renders above the box; helperText sits below it as a quiet caption. Both are optional.

FossTextField(
  label: 'Username',
  hintText: 'jane',
  helperText: 'This is your public handle.',
  onChanged: (value) => setState(() => username = value),
);

Sizes

Three heights: sm (30), md (34, the default), and lg (38). Every size keeps a 48px minimum tap target underneath.

FossTextField(
  size: FossTextFieldSize.sm,
  hintText: 'Compact',
);

FossTextField(
  size: FossTextFieldSize.lg,
  hintText: 'Prominent',
);

Icons

leading and trailing take any widget, so you can pass Lucide, Material, Cupertino, an SVG, or a custom icon. They are themed to match the text. Icons are single line only; a multiline field has no icon rail.

FossTextField(
  label: 'Email',
  hintText: 'you@example.com',
  leading: const Icon(LucideIcons.mail),
  keyboardType: TextInputType.emailAddress,
);

Password

Set obscureText: true to hide the value.

FossTextField(
  label: 'Password',
  obscureText: true,
  trailing: const Icon(LucideIcons.lock),
);

Error

A non-null errorText marks the field invalid and replaces the helper caption. The border and ring shift to the destructive color.

FossTextField(
  label: 'Email',
  errorText: 'Enter a valid email address.',
);

Multiline

Set maxLines to anything other than 1 (or null to grow without bound) for a textarea. It grows with content and top-aligns its text. minLines sets the resting line count, defaulting to 3.

FossTextField(
  label: 'Bio',
  hintText: 'Tell us about yourself',
  maxLines: 5,
  minLines: 3,
);

Disabled

Pass enabled: false to dim the field and stop it responding to input.

FossTextField(
  label: 'Locked',
  enabled: false,
);

Controlled

Pass a controller and focusNode to own the field's state. When omitted, the field creates and disposes its own.

final controller = TextEditingController();

FossTextField(
  controller: controller,
  label: 'Search',
  textInputAction: TextInputAction.search,
  onSubmitted: (value) => runSearch(value),
);

One-off styling

A single field can override the theme-resolved look with a FossTextFieldStyle. Every field is optional and falls back to the theme.

FossTextField(
  label: 'Rounded',
  style: const FossTextFieldStyle(
    borderRadius: 999,
    contentPadding: EdgeInsets.symmetric(horizontal: 16),
  ),
);

API

FossTextField

PropTypeDefaultDescription
labelString?nullLabel rendered above the box.
hintTextString?nullPlaceholder shown while empty.
helperTextString?nullCaption below the box. Hidden when errorText is set.
errorTextString?nullMarks the field invalid and replaces the helper caption.
sizeFossTextFieldSizemdThe field height.
enabledbooltrueWhether the field accepts input.
leadingWidget?nullWidget before the content, single line only.
trailingWidget?nullWidget after the content, single line only.
obscureTextboolfalseHides the text, for passwords.
keyboardTypeTextInputType?nullThe keyboard layout to request.
textInputActionTextInputAction?nullThe keyboard action button.
maxLinesint?1Above 1 or null makes it a multiline textarea.
minLinesint?nullStarting line count for a multiline field.
onChangedValueChanged<String>?nullCalled on every text change.
onSubmittedValueChanged<String>?nullCalled on keyboard submit.
controllerTextEditingController?nullHolds the text. Created internally when null.
focusNodeFocusNode?nullManages focus. Created internally when null.
styleFossTextFieldStyle?nullPer-instance overrides on the theme.

FossTextFieldSize

sm (30), md (34), lg (38).

Live demo

Open the interactive gallery to try every size and state with live knobs.

On this page