Articles in this section
Category / Section

How to Vertically Center Align Icons in Leading and Trailing Views in .NET MAUI TextInputLayout

2 mins read

In .NET MAUI, the TextInputLayout control allows you to create a text input field with additional features such as leading and trailing views. These views can contain icons, labels, or other elements that enhance the user interface. This article demonstrates how to vertically center align icons within the leading and trailing views of the .NET MAUI TextInputLayout.

XAML Implementation:
To center align an icon in the leading or trailing view of the TextInputLayout, you can use the VerticalTextAlignment property of the Label element that holds the icon. In this, the Label element within the LeadingView contains an icon represented by an emoji. The VerticalTextAlignment property is set to Center, which vertically centers the icon within the leading view.

XAML

    <StackLayout WidthRequest="200" HeightRequest="200">
        <inputLayout:SfTextInputLayout Hint="Date"
                                       LeadingViewPosition="Inside">
            <inputLayout:SfTextInputLayout.LeadingView>
                         <Label VerticalTextAlignment="Center" 
                                Text="🗓"  
                                FontSize="16" />
            </inputLayout:SfTextInputLayout.LeadingView>
            <Entry />
        </inputLayout:SfTextInputLayout>
    </StackLayout>

Output

Screenshot 2023-12-15 145208.png

Conclusion
I hope you enjoyed learning how to vertically center align icons in leading and trailing views in .NET MAUI TextInputLayout.

You can refer to our .NET MAUI TextInputLayout feature tour page to learn about its other groundbreaking feature representations. You can explore our .NET MAUI TextInputLayout documentation to understand how to present and manipulate data.

For current customers, check out our .NET MAUI components from the License and downloads page. If you are new to Syncfusion, try our 30-day free trial to check out our .NET MAUI TextInputLayout and other .NET MAUI components.

Please let us know in the following comments section if you have any queries or require clarifications. You can also contact us through our support forums, Direct - Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied