Skip to content

Commit 81226bc

Browse files
Merge pull request #5268 from syncfusion-content/ES-925700-TabSwipeHF
925700: Swipe mode API UG doc
2 parents 023cfe1 + 6db27c8 commit 81226bc

File tree

1 file changed

+47
-33
lines changed

1 file changed

+47
-33
lines changed

blazor/tabs/how-to/prevent-content-swipe-selection.md

Lines changed: 47 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,45 +7,59 @@ control: Tabs
77
documentation: ug
88
---
99

10+
1011
# Prevent content swipe selection in Blazor Tabs Component
1112

12-
The tab selection can be prevented on touch swipe action by using the Tab [Selecting](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.TabEvents.html#Syncfusion_Blazor_Navigations_TabEvents_Selecting) event.
13+
The [`SwipeMode`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.SfTab.html#Syncfusion_Blazor_Navigations_SfTab_SwipeMode) property in the Tab component allows users to navigate between tabs using swipe gestures, improving the overall navigation experience. It supports both touch and mouse inputs, enabling intuitive tab switching.
1314

14-
```cshtml
15-
@using Syncfusion.Blazor.Navigations
15+
However, in certain cases, such as when a tab contains critical elements like a form, accidental swipes can disrupt the user's workflow. For example, if a user is filling out a form and mistakenly swipes, the tab might change unexpectedly, potentially leading to unsaved data or interruptions.
16+
17+
To address this, you can customize the [`SwipeMode`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.SfTab.html#Syncfusion_Blazor_Navigations_SfTab_SwipeMode) property based on the needs of the application. By adjusting this setting, you can balance smooth, intuitive navigation with protecting the user experience and safeguarding against accidental tab switches.
18+
19+
The following are the available [`SwipeMode`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.SfTab.html#Syncfusion_Blazor_Navigations_SfTab_SwipeMode) options for the Tab component:
1620

17-
<SfTab>
18-
<TabEvents Selecting="Select">
19-
</TabEvents>
21+
* [`TabSwipeMode.Touch & TabSwipeMode.Mouse`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.TabSwipeMode.html) - By default, this option allows the user to swipe between tabs using both touch and mouse actions.
22+
* [`TabSwipeMode.Touch`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.TabSwipeMode.html) - This option allows users to swipe between tabs using touch gestures only.
23+
* [`TabSwipeMode.Mouse`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.TabSwipeMode.html) - This option allows users to swipe between tabs using mouse gestures only.
24+
* [`~TabSwipeMode.Touch & ~TabSwipeMode.Mouse`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.TabSwipeMode.html) - This disables both touch and mouse swipe actions, preventing any unintended tab switches.
25+
26+
```cshtml
27+
<SfTab SwipeMode="~TabSwipeMode.Touch & ~TabSwipeMode.Mouse">
2028
<TabItems>
21-
<TabItem Content="Twitter is an online social networking service that enables users to send and read short 140-charactermessages called tweets.Registered users can read and post tweets, but those who are unregistered can only readthem.Users access Twitter through the website interface, SMS or mobile device app Twitter Inc. is based in SanFrancisco and has more than 25 offices around the world.Twitter was created in March 2006 by Jack Dorsey,Evan Williams, Biz Stone, and Noah Glass and launched in July 2006. The service rapidly gained worldwide popularity,with more than 100 million users posting 340 million tweets a day in 2012.The service also handled 1.6 billionsearch queries per day.">
22-
<ChildContent>
23-
<TabHeader Text="Twitter">
24-
</TabHeader>
25-
</ChildContent>
26-
</TabItem>
27-
<TabItem Content="Facebook is an online social networking service headquartered in Menlo Park, California. Its website waslaunched on February 4, 2004, by Mark Zuckerberg with his Harvard College roommates and fellow students EduardoSaverin, Andrew McCollum, Dustin Moskovitz and Chris Hughes.">
28-
<ChildContent>
29-
<TabHeader Text="Facebook">
30-
</TabHeader>
31-
</ChildContent>
32-
</TabItem>
33-
<TabItem Content="WhatsApp Messenger is a proprietary cross-platform instant messaging client for smartphones that operatesunder a subscription business model.It uses the Internet to send text messages, images, video, user location andaudio media messages to other users using standard cellular mobile numbers. As of February 2016, WhatsApp had a userbase of up to one billion,[10] making it the most globally popular messaging application.WhatsApp Inc., based inMountain View, California, was acquired by Facebook Inc.on February 19, 2014, for approximately US$19.3 billion.">
34-
<ChildContent>
35-
<TabHeader Text="WhatsApp">
36-
</TabHeader>
37-
</ChildContent>
29+
<TabItem>
30+
<HeaderTemplate>India</HeaderTemplate>
31+
<ContentTemplate>
32+
<div>
33+
India officially the Republic of India, is a country in South Asia. It is the seventh-largest country by area, the second-most populous country with over 1.2 billion people, and the most populous democracy in the world. Bounded by the Indian Ocean on the south, the Arabian Sea on the south-west, and the Bay of Bengal on the south-east, it shares land borders with Pakistan to the west;China, Nepal, and Bhutan to the north-east; and Burma and Bangladesh to the east. In the Indian Ocean, India is in the vicinity of Sri Lanka and the Maldives; in addition, India Andaman and Nicobar Islands share a maritime border with Thailand and Indonesia.
34+
</div>
35+
</ContentTemplate>
36+
</TabItem>
37+
<TabItem>
38+
<HeaderTemplate>Australia</HeaderTemplate>
39+
<ContentTemplate>
40+
<div>
41+
Australia, officially the Commonwealth of Australia, is a country comprising the mainland of the Australian continent, the island of Tasmania and numerous smaller islands. It is the world sixth-largest country by total area. Neighboring countries include Indonesia, East Timor and Papua New Guinea to the north; the Solomon Islands, Vanuatu and New Caledonia to the north-east; and New Zealand to the south-east.
42+
</div>
43+
</ContentTemplate>
44+
</TabItem>
45+
<TabItem>
46+
<HeaderTemplate>USA</HeaderTemplate>
47+
<ContentTemplate>
48+
<div>
49+
The United States of America (USA or U.S.A.), commonly called the United States (US or U.S.) and America, is a federal republic consisting of fifty states and a federal district. The 48 contiguous states and the federal district of Washington, D.C. are in central North America between Canada and Mexico. The state of Alaska is west of Canada and east of Russia across the Bering Strait, and the state of Hawaii is in the mid-North Pacific. The country also has five populated and nine unpopulated territories in the Pacific and the Caribbean.
50+
</div>
51+
</ContentTemplate>
52+
</TabItem>
53+
<TabItem>
54+
<HeaderTemplate>France</HeaderTemplate>
55+
<ContentTemplate>
56+
<div>
57+
France, officially the French Republic is a sovereign state comprising territory in western Europe and several overseas regions and territories. The European part of France, called Metropolitan France, extends from the Mediterranean Sea to the English Channel and the North Sea, and from the Rhine to the Atlantic Ocean; France covers 640,679 square kilo metres and as of August 2015 has a population of 67 million, counting all the overseas departments and territories.
58+
</div>
59+
</ContentTemplate>
3860
</TabItem>
3961
</TabItems>
4062
</SfTab>
63+
```
4164

42-
@code {
43-
public void Select(SelectingEventArgs args)
44-
{
45-
if(args.IsSwiped)
46-
{
47-
args.Cancel = true;
48-
}
49-
}
50-
}
51-
```
65+
{% previewsample "https://blazorplayground.syncfusion.com/embed/LjLzsrsrTlqFIhjX?appbar=true&editor=true&result=true&errorlist=true&theme=bootstrap5" %}

0 commit comments

Comments
 (0)