Introducing the New .NET MAUI Text Input Layout

Jollen Moyani - Jan 10 '23 - - Dev Community

A text input layout control was one of the most-requested controls by our mobile app developers. We understand the requirement for this essential control and have now delivered the .NET MAUI Text Input Layout control in our 2022 Volume 4 release.

This control can be used to build UIs that require user input. It allows users to add floating labels, password toggle icons, leading and trailing icons, and assistive labels such as error messages and help text on top of the input controls. These features help improve the interface’s usability and make it easier for users to enter and submit information.

In this article, we will see the key features of the new .NET MAUI Text Input Layout and the steps to get started with it.

Key features

The .NET MAUI Text Input Layout supports numerous user-friendly features. Some of them are listed here.

Supported input controls

The .NET MAUI Text Input Layout control can enhance the appearance and functionality of the Syncfusion Autocomplete or ComboBox controls, and the Microsoft Entry and Editor controls in the .NET MAUI framework.

By wrapping these input views with the Text Input Layout, you can easily add assistive labels and icons to improve your app’s usability and visual appeal.

.NET MAUI Text Input Layout’s Supported Input Controls

.NET MAUI Text Input Layout’s Supported Input Controls

Container types

The .NET MAUI Text Input Layout supports the following container types:

  • Filled: The background of the input view will fill with the container color, and the baseline stroke and thickness will change based on the state of the input view.
  • Outlined: The container will be framed with a rounded border.
  • None: The container will have an empty background and space around it.

.NET MAUI Text Input Layout's Container Types

.NET MAUI Text Input Layout's Container Types

Supported states

The .NET MAUI Text Input Layout supports the focused, unfocused, error, and disabled visual states.

.NET MAUI Text Input Layout’s Supported States

.NET MAUI Text Input Layout’s Supported States

Toggling password visibility

You can enable the password toggle icon to show or hide a password interactively.

Password Visibility Toggling in .NET MAUI Text Input Layout

Password Visibility Toggling in .NET MAUI Text Input Layout

Floating labels and hints

Use the hint text feature to add placeholder text to the input view. This hint text will be displayed in the middle of the input view and will move to the top to become a floating label when the input field becomes active. This can help save space and avoid the need for additional titles.

Floating Labels and Hints in .NET MAUI Text Input Layout

Floating Labels and Hints in .NET MAUI Text Input Layout

Helper text

In addition to the hint text, the Text Input Layout control also provides a helper text feature. It allows you to display additional information about the text that is expected to be entered. This can be useful for giving instructions or examples to help users understand how to correctly enter details in the input field.

Helper Text in .NET MAUI Text Input Layout

Helper Text in .NET MAUI Text Input Layout

Error text

Use the error text feature to display error messages that assist users in solving validation errors. This can improve the usability of your app by providing clear feedback to users when there are problems with their input.

.NET MAUI Text Input Layout Displaying Error Text

.NET MAUI Text Input Layout Displaying Error Text

Leading and trailing icons

You can use leading icons to indicate the expected input type, such as a birth date, phone number, or password. These can help users understand the purpose of the input field and easily enter the appropriate information.

Trailing icons, on the other hand, can be used for various purposes, such as adding a clear button, error icon, voice input icon, or drop-down icon. These can improve the functionality of the input view and make it easier for users to interact with it.

Leading and Trailing Icons in .NET MAUI Text Input Layout

Leading and Trailing Icons in .NET MAUI Text Input Layout

Note: For more details, refer to the .NET MAUI Text Input Layout documentation.

Getting started with the .NET MAUI Text Input Layout control

We have seen the key features of the .NET MAUI Text Input Layout (SfTextInputLayout). Let’s see how to configure it with a floating label.

Step 1: First, create a .NET MAUI application.

Step 2: The Syncfusion .NET MAUI controls are available on NuGet Gallery. To add the .NET MAUI Text Input Layout control to your project, open the NuGet package manager in Visual Studio. Search for Syncfusion.Maui.Core and then install it.

Step 3: Now, register the handler for the Syncfusion core in the MauiProgram.cs file.

using Microsoft.Maui;
using Microsoft.Maui.Hosting;
using Microsoft.Maui.Controls.Compatibility;
using Microsoft.Maui.Controls.Hosting;
using Microsoft.Maui.Controls.Xaml;
using Syncfusion.Maui.Core.Hosting;
namespace TextInputLayoutSample
{
  public static class MauiProgram
  {
    public static MauiApp CreateMauiApp()
    {
        var builder = MauiApp.CreateBuilder();
        builder
        .UseMauiApp<App>()
        .ConfigureSyncfusionCore()
        .ConfigureFonts(fonts =>
        {
               fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
        });
        return builder.Build();
     }
  }
}
Enter fullscreen mode Exit fullscreen mode

Step 3: Add Syncfusion.Maui.Core namespace in your XAML page.

xmlns:inputLayout="clr-namespace:Syncfusion.Maui.Core;assembly=Syncfusion.Maui.Core"
Enter fullscreen mode Exit fullscreen mode

Step 4: Then, add any input view control such as Entry, Editor, Autocomplete, or ComboBox to the Text Input Layout.

<inputLayout:SfTextInputLayout>
   <Entry />
</inputLayout:SfTextInputLayout>
Enter fullscreen mode Exit fullscreen mode

Step 5: Now, we can add the floating label for the Text Input Layout by setting the Hint property with the text you want to display as the label. You can also control the visibility of the hint by setting the ShowHint property as true or false. By default, it’s set to true to display the floating label.

Refer to the following code example.

<inputLayout:SfTextInputLayout Hint="First Name">
   <Entry Text = "Selva Ganapathy Kathiresan"/>
</inputLayout:SfTextInputLayout>
Enter fullscreen mode Exit fullscreen mode

.NET MAUI Text Input Layout Displaying Floating Label

.NET MAUI Text Input Layout Displaying Floating Label

Conclusion

Thanks for reading! In this blog, we’ve seen the features of the new .NET MAUI Text Input Layout control rolled out in the 2022 Volume 4 release. Information about our other new controls and features is available in our Release Notes and What’s New pages. Try them out and leave your feedback in the comments section below!

Download Essential Studio for .NET MAUI to start evaluating them immediately.

If you have any questions or need further assistance, please don’t hesitate to contact us through our support forum, support portal, or feedback portal. We are always happy to help you!

Related blogs

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .