Search code examples
flutterflutter-textinputfield

How to set style for a text field label when the input is active?


On the image below the Demo Text label by default a little bit small. I tried to change labelSmall and labelMedium styles but it doesn't work for that. What style is responsible for that?

enter image description here


Solution

  • You can use floatingLabelStyle in InputDecoration of the TextField

    Example:

        TextField(
          decoration: InputDecoration(
            floatingLabelStyle: TextStyle(
              color: Colors.red,
              fontSize: 12
            ),
            labelText: 'Demo Text',
            labelStyle: TextStyle(
              fontSize: 16
            )
          ),
        ),