Skip to Content

A text input component for collecting user text input with labels, hints, and helper text.

When to use this

  • Form inputs: Collect text data in forms (names, emails, addresses)
  • Search fields: Enable users to enter search queries
  • Comments: Allow users to enter text comments or feedback
  • Data entry: Capture any text-based user input

Basic implementation

Basic implementation
import 'package:flutter/material.dart'; import 'package:remix/remix.dart'; class TextfieldExample extends StatefulWidget { const TextfieldExample({super.key}); @override State<TextfieldExample> createState() => _TextfieldExampleState(); } class _TextfieldExampleState extends State<TextfieldExample> { final controller = TextEditingController(); @override Widget build(BuildContext context) { return SizedBox( width: 300, child: RemixTextField( controller: controller, hintText: 'Placeholder', label: 'Label', helperText: 'Required field', style: style, ), ); } RemixTextFieldStyle get style { return RemixTextFieldStyle() .color(Colors.grey.shade800) .backgroundColor(Colors.white) .borderRadiusAll(const Radius.circular(8.0)) .height(44) .paddingX(12) .spacing(8) .label( TextStyler() .color(Colors.blueGrey.shade900) .fontWeight(FontWeight.w500), ) .helperText( TextStyler() .fontWeight(FontWeight.w300) .color(Colors.blueGrey.shade600), ) .hintColor(Colors.blueGrey.shade500) .shadow( BoxShadowMix() .blurRadius(1) .color(Colors.black12) .offset(const Offset(0, 1)), ) .border( BoxBorderMix.all(BorderSideMix(color: Colors.grey.shade300)), ) .onFocused( RemixTextFieldStyle().border( BoxBorderMix.all( BorderSideMix() .color(Colors.deepPurpleAccent) .width(3) .strokeAlign(BorderSide.strokeAlignCenter), ), ), ); } }

Interactive preview

Resolving preview metadata...

Fortal styles

Remix includes Fortal-themed style helpers for this component:

Fortal base style
import 'package:flutter/material.dart'; import 'package:remix/remix.dart'; class FortalTextFieldExample extends StatefulWidget { const FortalTextFieldExample({super.key}); @override State<FortalTextFieldExample> createState() => _FortalTextFieldExampleState(); } class _FortalTextFieldExampleState extends State<FortalTextFieldExample> { final controller = TextEditingController(); @override Widget build(BuildContext context) { return Column( spacing: 16, children: [ RemixTextField( controller: controller, label: 'Email', hintText: 'Enter your email', style: FortalTextFieldStyle.base(), ), RemixTextField( controller: controller, label: 'Password', hintText: 'Enter password', obscureText: true, style: FortalTextFieldStyle.base(), ), ], ); } }

See the FortalTextFieldStyle source code  for all available options.

Constructor

Constructor
const RemixTextField({ Key? key, TextEditingController? controller, FocusNode? focusNode, String? label, String? hintText, String? helperText, bool error = false, TextInputType? keyboardType, TextInputAction? textInputAction, TextCapitalization textCapitalization = TextCapitalization.none, TextDirection? textDirection, bool obscureText = false, bool enabled = true, bool readOnly = false, bool autofocus = false, int? maxLines = 1, int? minLines, bool expands = false, int? maxLength, MaxLengthEnforcement? maxLengthEnforcement, ValueChanged<String>? onChanged, VoidCallback? onEditingComplete, ValueChanged<String>? onSubmitted, AppPrivateCommandCallback? onAppPrivateCommand, List<TextInputFormatter>? inputFormatters, bool? showCursor, String obscuringCharacter = '•', bool autocorrect = true, bool enableSuggestions = true, SmartDashesType? smartDashesType, SmartQuotesType? smartQuotesType, DragStartBehavior dragStartBehavior = DragStartBehavior.start, bool enableInteractiveSelection = true, TextSelectionControls? selectionControls, TapRegionCallback? onTapOutside, TapRegionUpCallback? onPressUpOutside, bool onTapAlwaysCalled = false, ScrollController? scrollController, ScrollPhysics? scrollPhysics, Iterable<String>? autofillHints, ContentInsertionConfiguration? contentInsertionConfiguration, Clip clipBehavior = Clip.hardEdge, String? restorationId, bool stylusHandwritingEnabled = true, bool enableIMEPersonalizedLearning = true, EditableTextContextMenuBuilder? contextMenuBuilder, SpellCheckConfiguration? spellCheckConfiguration, TextMagnifierConfiguration? magnifierConfiguration, bool canRequestFocus = true, bool? ignorePointers, UndoHistoryController? undoController, Object groupId = EditableText, Widget? leading, Widget? trailing, String? semanticLabel, String? semanticHint, bool excludeSemantics = false, RemixTextFieldStyle style = const RemixTextFieldStyle.create(), RemixTextFieldSpec? styleSpec, })

Properties

Widget Properties

PropTypeRequired / Default Value
keyKey?Optional. Controls how one widget replaces another widget in the tree.
controllerTextEditingController?Optional. Controls the text being edited.
focusNodeFocusNode?Optional. Defines the keyboard focus for this widget.
keyboardTypeTextInputType?Optional. The type of keyboard to use for editing the text.
textInputActionTextInputAction?Optional. The type of action button to use for the keyboard.
textCapitalizationTextCapitalizationOptional. Configures how the platform keyboard will select an uppercase or lowercase keyboard.
textDirectionTextDirection?Optional. The directionality of the text.
readOnlyboolOptional. Whether the text can be changed.
showCursorbool?Optional. Whether to show cursor.
autofocusboolOptional. Whether this text field should focus itself if nothing else is already focused.
obscuringCharacterStringOptional. Character used for obscuring text if obscureText is true.
obscureTextboolOptional. Whether to hide the text being edited.
autocorrectboolOptional. Whether to enable autocorrect.
enableSuggestionsboolOptional. Whether to show input suggestions as the user types.
smartDashesTypeSmartDashesType?Optional. Configuration for smart dashes.
smartQuotesTypeSmartQuotesType?Optional. Configuration for smart quotes.
maxLinesint?Optional. The maximum number of lines for the text to span.
minLinesint?Optional. The minimum number of lines to occupy when the content spans fewer lines.
expandsboolOptional. Whether this widget’s height will be sized to fill its parent.
maxLengthint?Optional. The maximum number of characters to allow in the text field.
maxLengthEnforcementMaxLengthEnforcement?Optional. How the maxLength limit should be enforced.
onChangedValueChanged<String>?Optional. Called when the user initiates a change to the TextField’s value.
onEditingCompleteVoidCallback?Optional. Called when the user submits editable content.
onSubmittedValueChanged<String>?Optional. Called when the user indicates that they are done editing the text in the field.
onAppPrivateCommandAppPrivateCommandCallback?Optional. This is used to receive a private command from the input method.
inputFormattersList<TextInputFormatter>?Optional. Optional input formatters.
enabledboolOptional. Whether the text field is enabled.
dragStartBehaviorDragStartBehaviorOptional. Defines how to handle drag start behavior.
enableInteractiveSelectionboolOptional. Whether to enable user interface affordances for changing the text selection.
selectionControlsTextSelectionControls?Optional. Optional delegate for building the text selection handles and toolbar.
onTapOutsideTapRegionCallback?Optional. Called when the user taps outside of this text field.
onPressUpOutsideTapRegionUpCallback?Optional. Called when tap up is detected outside of this text field.
onTapAlwaysCalledboolOptional. Whether onTap should be called for every tap.
scrollControllerScrollController?Optional. The ScrollController to use when vertically scrolling the input.
scrollPhysicsScrollPhysics?Optional. The ScrollPhysics to use when vertically scrolling the input.
autofillHintsIterable<String>?Optional. A list of strings that helps the autofill service identify the type of this text input.
contentInsertionConfigurationContentInsertionConfiguration?Optional. Configuration for content insertion.
clipBehaviorClipOptional. The content will be clipped (or not) according to this option.
restorationIdString?Optional. Restoration ID to save and restore the state of the text field.
stylusHandwritingEnabledboolOptional. Whether stylus handwriting is enabled.
enableIMEPersonalizedLearningboolOptional. Whether to enable that the IME update personalized data.
contextMenuBuilderEditableTextContextMenuBuilder?Optional. A context menu builder for the text field.
spellCheckConfigurationSpellCheckConfiguration?Optional. Configuration for spell checking.
magnifierConfigurationTextMagnifierConfiguration?Optional. Configuration for text magnification.
canRequestFocusboolOptional. Whether this text field can request focus.
ignorePointersbool?Optional. Whether to ignore pointer events.
undoControllerUndoHistoryController?Optional. Undo controller for managing undo/redo operations.
groupIdObjectOptional. The group ID for the text field.
hintTextString?Optional. Hint text to display when the text field is empty.
helperTextString?Optional. Helper text to display below the text field.
labelString?Optional. Label text to display above the text field.
errorboolOptional. Whether the text field is in error state.
styleSpecRemixTextFieldSpec?Optional. The style spec for the text field.
leadingWidget?Optional. A widget to display at the leading edge of the text field.
trailingWidget?Optional. A widget to display at the trailing edge of the text field.
semanticLabelString?Optional. The semantic label for the text field.
semanticHintString?Optional. The semantic hint for the text field.
excludeSemanticsboolOptional. Whether to exclude child semantics.
styleRemixTextFieldStyleOptional. The style configuration for the text field.

Style Methods

MethodDescription
color(Color value)Sets text color
backgroundColor(Color value)Sets background color
container(FlexBoxStyler value)Sets container that wraps editable text area
borderRadius(BorderRadiusGeometryMix radius)Sets border radius
padding(EdgeInsetsGeometryMix value)Sets padding
border(BoxBorderMix value)Sets border
width(double value)Sets width
height(double value)Sets height
cursorColor(Color value)Sets cursor color
hintColor(Color value)Sets hint text color
hintText(TextStyler value)Sets hint text style using a TextStyler.
margin(EdgeInsetsGeometryMix value)Sets margin
spacing(double value)Sets flex spacing
decoration(DecorationMix value)Sets decoration
alignment(Alignment value)Sets container alignment
constraints(BoxConstraintsMix value)Sets constraints
textAlign(TextAlign value)Sets text alignment
helperText(TextStyler value)Sets helper text
label(TextStyler value)Sets label text
animate(AnimationConfig animation)Sets animation
wrap(WidgetModifierConfig value)Applies widget modifiers such as clipping, opacity, or scaling.
foregroundDecoration(DecorationMix value)Sets a foreground decoration painted on top of the component.
transform(Matrix4 value, AlignmentGeometry alignment = Alignment.center)Applies a matrix transformation to the component.
flex(FlexStyler value)Configures the flex layout properties.
labelTextStyle(TextStyleMix value)Sets label/text style using TextStyleMix directly
labelColor(Color value)Sets label/text color
labelFontSize(double value)Sets label/text font size
labelFontWeight(FontWeight value)Sets label/text font weight
labelFontStyle(FontStyle value)Sets label/text font style (italic/normal)
labelLetterSpacing(double value)Sets label/text letter spacing
labelDecoration(TextDecoration value)Sets label/text decoration (underline, strikethrough, etc.)
labelFontFamily(String value)Sets label/text font family
labelHeight(double value)Sets label/text line height
labelWordSpacing(double value)Sets label/text word spacing
labelDecorationColor(Color value)Sets label/text decoration color
Last updated on

This package is currently in development — see GitHub for details.