Articles in this section
Category / Section

How to customize the tab item in .NET MAUI Tab View?

4 mins read

Overview

Enhance the user interface in .NET MAUI Tab View by adding font icons to the TabItems along with header text. This is achieved by using the FontImageSource element within your XAML code. Below is a step-by-step guide on how to customize your TabItems with font icons.

Adding Font Icons to TabItems

To add font icons to your TabItems, use the FontImageSource element within each SfTabItem. Here’s an example of how to do this:

<tabView:SfTabView x:Name="tabView" TabBarBackground="HotPink">
    <tabView:SfTabView.Items>
        <!-- TabItem with a Call icon -->
        <tabView:SfTabItem Header="Call" x:Name="callItem" ImagePosition="Left">
            <tabView:SfTabItem.ImageSource>
                <FontImageSource Glyph="ﺶ" x:Name="call"
                                 Color="{Binding Source={x:Reference callItem},Path=TextColor}"
                                 FontFamily="MaterialDesignIcons"/>
            </tabView:SfTabItem.ImageSource>
            <!-- Content for the Call tab -->
            <!-- ... -->
        </tabView:SfTabItem>

        <!-- TabItem with a Favourite icon -->
        <tabView:SfTabItem Header="Favourite" x:Name="favItem" ImagePosition="Left">
            <tabView:SfTabItem.ImageSource>
                <FontImageSource Glyph="" x:Name="fav"
                                 Color="{Binding Source={x:Reference favItem},Path=TextColor}"
                                 FontFamily="MaterialDesignIcons"/>
            </tabView:SfTabItem.ImageSource>
            <!-- Content for the Favourite tab -->
            <!-- ... -->
        </tabView:SfTabItem>

        <!-- TabItem with a Contacts icon -->
        <tabView:SfTabItem Header="Contacts" x:Name="contactsItem" ImagePosition="Left">
            <tabView:SfTabItem.ImageSource>
                <FontImageSource Glyph="" x:Name="contacts"
                                 Color="{Binding Source={x:Reference contactsItem},Path=TextColor}"
                                 FontFamily="MaterialDesignIcons"/>
            </tabView:SfTabItem.ImageSource>
            <!-- Content for the Contacts tab -->
            <!-- ... -->
        </tabView:SfTabItem>
    </tabView:SfTabView.Items>
</tabView:SfTabView>

In the above example, each SfTabItem has an ImageSource defined with a FontImageSource. The Glyph attribute is used to specify the icon, and the Color attribute is bound to the TextColor of the tab item, ensuring that the icon color matches the text color. The FontFamily should be set to the font that contains your icons, such as “MaterialDesignIcons” in this case.

Binding the Icon Color

To ensure that the icon color matches the text color of the tab, bind the icon color to the TextColor property of the SfTabItem using the syntax {Binding Source={x:Reference NameOfTabItem}, Path=TextColor}.

Output

TabView.gif

Note:
Remember to include the font file containing your icons in your project and set the appropriate build action for it. This will ensure that the icons are displayed correctly in your application.

Download the complete sample from GitHub

Conclusion

I hope you enjoyed learning how to customize the tab item in .NET MAUI Tab View.

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

You can check out our .NET MAUI components from the License and Downloads page for current customers. If you are new to Syncfusion®, try our 30-day free trial to check out our .NET MAUI Tab View and other .NET MAUI components.

Please let us know in the comments section if you have any queries or require clarification. 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