DEV Community

Cover image for The All-New .NET MAUI Tab View Control Is Here
Suresh Mohan for Syncfusion, Inc.

Posted on • Originally published at syncfusion.com on

The All-New .NET MAUI Tab View Control Is Here

The .NET Multi-platform App UI (MAUI) is an evolution of Xamarin.Forms. It mainly focuses on single project development for different platforms such as Android, iOS, macOS, and Windows.

Syncfusion has shipped a set of cool .NET MAUI tools that includes Charts, Radial Gauge, and Tab View controls in the 2021 Volume 3 release. These controls are really fast, feature-rich, and flexible to use in your .NET MAUI applications.

In this blog, we will introduce the .NET MAUI Tab View control along with code examples.

.NET MAUI Tab View (Preview)

The advanced .NET MAUI Tab View is a simple and intuitive interface for tab navigation. You can use it in both mobile and desktop applications, wherever you want your users to explore and switch between different tabs.

Tab View overview

  • Optimizes screen space usage when an application requires complex and huge layouts.
  • Contains a set of tab items that present different content in the same space.
  • Shows only one tab item at a time to be accessed by the user. The user taps another tab to make its content visible on the screen.

Tab width mode

The .NET MAUI Tab View provides two width options: default and size to content. These options determine how to calculate the width of the tabs on the tab bar when it is populated.

Default

In the default option, the width of all the tabs is equally divided based on the width of the tab bar. This enables a fixed tab bar that does not allow tab scrolling regardless of its number of tabs.

<syncfusion:SfTabView TabWidthMode="Default" />
Enter fullscreen mode Exit fullscreen mode

Default Tab Width Mode
Default Tab Width Mode

Size to content

You can use this option when you need to set the width of a tab so that it fits the text or image that it contains. This option enables tab scrolling when the arrangement of the tabs and their width exceeds the tab bar’s width.

<syncfusion:SfTabView TabWidthMode="SizeToContent" />
Enter fullscreen mode Exit fullscreen mode

Size To Content Tab Width Mode
Size To Content Tab Width Mode

Tab image position

The .NET MAUI Tab View provides four options that determine how an image in a tab aligns relative to the tab’s text. The available options are top, bottom, left, and right.

Top

The top option places the image above the text.

<syncfusion:SfTabItem ImagePosition="Top"/>
Enter fullscreen mode Exit fullscreen mode

Placing Tab Image at the Top
Placing the Tab Image at the Top

Bottom

The bottom option places the image below the text.

<syncfusion:SfTabItem ImagePosition="Bottom"/>
Enter fullscreen mode Exit fullscreen mode

Placing Tab Image at the Bottom
Placing the Tab Image at the Bottom

Left

The left option places the image before the text.

<syncfusion:SfTabItem ImagePosition="Left"/>
Enter fullscreen mode Exit fullscreen mode

Placing Tab Image at the Left
Placing the Tab Image at the Left

Right

The right option places the image after the text.

<syncfusion:SfTabItem ImagePosition="Right"/>
Enter fullscreen mode Exit fullscreen mode

Placing Tab Image at the Right
Placing the Tab Image at the Right

Selection indicator placement

The .NET MAUI Tab View provides three options that determine how the selection indicator aligns relative to the tab header item content. The available options are top, bottom, and fill.

Top

The selection indicator is places at the top of the selected tab.

<syncfusion:SfTabView IndicatorPlacement="Top" />
Enter fullscreen mode Exit fullscreen mode

Placing the Selection Indicator at the Top
Placing the Selection Indicator at the Top

Bottom

The selection indicator is placed at the bottom of the selected tab.

<syncfusion:SfTabView IndicatorPlacement="Bottom" />
Enter fullscreen mode Exit fullscreen mode

Placing Selection Indicator at the Bottom
Placing the Selection Indicator at the Bottom

Fill

The selection indicator fills the selected tab.

<syncfusion:SfTabView IndicatorPlacement="Fill" />
Enter fullscreen mode Exit fullscreen mode

Fill Selection Indicator on the Selected Tab
Fill Selection Indicator on the Selected Tab

Tab bar placement

The .NET MAUI Tab View provides two options that determine how the tab bar aligns relative to the tab content. The available options are top and bottom.

Top

The tab bar will be placed above the content region of the Tab View control.

<syncfusion:SfTabView TabBarPlacement="Top" />
Enter fullscreen mode Exit fullscreen mode

Placing the Tab Bar at the Top of the Tab Content
Placing the Tab Bar at the Top of the Tab Content

Bottom

The tab bar will be placed below the content region of the Tab View control.

<syncfusion:SfTabView TabBarPlacement="Bottom" />
Enter fullscreen mode Exit fullscreen mode

Placing the Tab Bar at the Bottom of the Tab Content
Placing the Tab Bar at the Bottom of the Tab Content

Nested tabs

This support allows users to have a nested tab view. You can also configure a tab view within another tab view through its Items property.

<syncfusion:SfTabView>
<syncfusion:SfTabItem Header="Item 1">
<syncfusion:SfTabView>
<syncfusion:SfTabItem Header="Item 1 SubItem 1"/>
<syncfusion:SfTabItem Header="Item 1 SubItem 2"/>
</syncfusion:SfTabView>
</syncfusion:SfTabItem>
<syncfusion:SfTabItem Header="Item 2">
<syncfusion:SfTabView>
<syncfusion:SfTabItem Header="Item 2 SubItem 1"/>
<syncfusion:SfTabItem Header="Item 2 SubItem 2"/>
</syncfusion:SfTabView>
</syncfusion:SfTabItem>
</syncfusion:SfTabView>
Enter fullscreen mode Exit fullscreen mode

Ripple animation

The built-in ripple animation matches the Material theme. This animation also provides a better taping experience to the user.

Color and font customization

You can easily customize all fonts and theirs colors with simple APIs.

Tab Bar with Customized Font and Colors
Tab Bar with Customized Font and Colors

Visual state manager

Use the visual state manager to make changes to the .NET MAUI Tab View item properties based on the visual states set in the code. The applicable visual states are selected, normal, enable and disable.

<Style TargetType="TabView:SfTabItem">
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup>
<VisualState x:Name="Selected" >
<VisualState.Setters>
<Setter Property="TextColor" Value="Red" />
<Setter Property="ImagePosition" Value="Top" />
<Setter Property="FontSize" Value="16" />
<Setter Property="FontAttributes" Value="Bold" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Normal">
<VisualState.Setters>
<Setter Property="TextColor" Value="Black" />
<Setter Property="ImagePosition" Value="Left" />
<Setter Property="FontSize" Value="12" />
<Setter Property="FontAttributes" Value="Italic" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
Enter fullscreen mode Exit fullscreen mode

Designing Tab Items with Visual State Manager
Designing Tab Items with Visual State Manager

Conclusion

Thanks for reading! In this blog post, we have gone through the features of .NET MAUI Tab View control rolled out in the 2021 Volume 3 release. Also, we are planning to provide several more features like an action button, overflow button, swipe navigation, and more. You can download the assemblies from NuGet to evaluate this new control. Check out our Release Notes and What’s New pages for more details.

We are also planning to deliver more .NET MAUI controls to replace our existing Syncfusion Xamarin.Forms controls. You can expect them in our upcoming releases!

Do you need any other features from this .NET MAUI Tab View? Please comment below or mention them in our support forum, Direct-Trac, or feedback portal. We are always happy to assist you!

Related blogs

Discussion (1)

Collapse
jayjeckel profile image
Jay Jeckel

Any way to make it look like a real tab control with actual tabs? And what about all the screen real estate wasted by those huge paddings and margins, anyway to get rid of that?