Search results

Tab

Tab is a content panel to show multiple contents in a single space, one at a time. Each Tab item has an associated content, that will be displayed based on the active Tab header item.

<div id="tab"></div>
<script>
  var tabObj = new Tab();
  tab.appendTo("#tab");
</script>

Properties

allowDragAndDrop

boolean

Sets true to allow drag and drop the Tab items

Defaults to false

animation

TabAnimationSettingsModel

Specifies the animation configuration settings while showing the content of the Tab.

Defaults to { previous: { effect: ‘SlideLeftIn’, duration: 600, easing: ‘ease’ },next: { effect: ‘SlideRightIn’, duration: 600, easing: ‘ease’ } }

clearTemplates

boolean

Specifies whether the templates need to be cleared or not while changing the Tab items dynamically.

Defaults to true

cssClass

string

Sets the CSS classes to root element of the Tab that helps to customize component styles.

Defaults to

dragArea

string

Defines the area in which the draggable element movement will be occurring. Outside that area will be restricted for the draggable element movement. By default, the draggable element movement occurs in the toolbar.

Defaults to null

enableHtmlSanitizer

boolean

Specifies whether to enable the rendering of untrusted HTML values in the Tab component. When this property is enabled, the component will sanitize any suspected untrusted strings and scripts before rendering them.

Defaults to true

enablePersistence

boolean

Enable or disable persisting component’s state between page reloads. If enabled, following list of states will be persisted.

  1. selectedItem

Defaults to false

enableRtl

boolean

Enable or disable rendering component in right to left direction.

Defaults to false

headerPlacement

HeaderPosition

Specifies the orientation of Tab header. The possible values for this property as follows

  • Top: Places the Tab header on the top.
  • Bottom: Places the Tab header at the bottom.
  • Left: Places the Tab header on the left.
  • Right: Places the Tab header at the right.

Defaults to ‘Top’

height

string | number

Specifies the height of the Tab component. By default, Tab height is set based on the height of its parent. To use height property, heightAdjustMode must be set to ‘None’.

Defaults to ‘auto’

heightAdjustMode

HeightStyles

Specifies the height style for Tab content. The possible values for this property as follows

  • None: Based on the given height property, the content panel height is set.
  • Auto: Tallest panel height of a given Tab content is set to all the other panels.
  • Content: Based on the corresponding content height, the content panel height is set.
  • Fill: Based on the parent height, the content panel height is set.

Defaults to ‘Content’

items

TabItemModel[]

An array of object that is used to configure the Tab component.

import { Tab } from "@syncfusion/ej2-navigations";

let tabObj: Tab = new Tab({
  items: [
    { header: { text: "Twitter" }, content: "Twitter is an online social networking service that enables users to send and read short 140-character messages called tweets. Registered users can read and post tweets, but those who are unregistered can only read them. Users access Twitter through the website interface, SMS or mobile device app Twitter Inc. is based in San Francisco 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 billion search queries per day." },

    { header: { text: "Facebook" }, content: "Facebook is an online social networking service headquartered in Menlo Park, California. Its website was launched on February 4, 2004, by Mark Zuckerberg with his Harvard College roommates and fellow students Eduardo Saverin, Andrew McCollum, Dustin Moskovitz and Chris Hughes. The founders had initially limited the website's membership to Harvard students, but later expanded it to colleges in the Boston area, the Ivy League, and Stanford University. It gradually added support for students at various other universities and later to high-school students." },
  ],
});
tabObj.appendTo("#tab");

Defaults to []

locale

string

Overrides the global culture and localization value for this component. Default global culture is ‘en-US’.

Defaults to

overflowMode

OverflowMode

Specifies the Tab display mode when Tab content exceeds the viewing area. The possible modes are:

  • Scrollable: All the elements are displayed in a single line with horizontal scrolling enabled.
  • Popup: Tab container holds the items that can be placed within the available space and rest of the items are moved to the popup. If the popup content overflows the height of the page, the rest of the elements can be viewed by scrolling the popup.

Defaults to ‘Scrollable’

reorderActiveTab

boolean

Determines whether to re-order tab items to show active tab item in the header area or popup when OverflowMode is Popup. True, if active tab item should be visible in header area instead of pop-up. The default value is true.

Defaults to true

scrollStep

number

Specifies the scrolling distance in scroller.

Defaults to null

selectedItem

number

Specifies the index for activating the current Tab item.

<div id="Tab"></div>
import { Tab } from "@syncfusion/ej2-navigations";
let tabObj = new Tab({
  selectedItem: 2,
  items: [
    {
      header: { text: "India" },
      content: "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.",
    },
    {
      header: { text: "Australia" },
      content: "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.",
    },
    {
      header: { text: "USA" },
      content: "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.",
    },
    {
      header: { text: "France" },
      content: "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.",
    },
  ],
});
tabObj.appendTo("#Tab");

Defaults to 0

showCloseButton

boolean

Specifies whether to show the close button for header items to remove the item from the Tab.

Defaults to false

width

string | number

Specifies the width of the Tab component. Default, Tab width sets based on the width of its parent.

Defaults to ‘100%’

Methods

addEventListener

Adds the handler to the given event listener.

Parameter Type Description
eventName string A String that specifies the name of the event
handler Function Specifies the call to run when the event occurs.

Returns void

addTab

Adds new items to the Tab that accepts an array as Tab items.

Parameter Type Description
items TabItemModel[] An array of item that is added to the Tab.
index (optional) number Number value that determines where the items to be added. By default, index is 0.

Returns void

appendTo

Appends the control within the given HTML element

Parameter Type Description
selector (optional) string | HTMLElement Target element where control needs to be appended

Returns void

attachUnloadEvent

Adding unload event to persist data when enable persistence true

Returns void

dataBind

When invoked, applies the pending property changes immediately to the component.

Returns void

destroy

Removes the component from the DOM and detaches all its related event handlers, attributes and classes.

Returns void

detachUnloadEvent

Removing unload event to persist data when enable persistence true

Returns void

disable

Specifies the value to disable/enable the Tab component. When set to true, the component will be disabled.

Parameter Type Description
value boolean Based on this Boolean value, Tab will be enabled (false) or disabled (true).

Returns void

enableTab

Enables or disables the specified Tab item. On passing value as false, the item will be disabled.

Parameter Type Description
index number Index value of target Tab item.
value boolean Boolean value that determines whether the command should be enabled or disabled.
By default, isEnable is true.

Returns void

getItemIndex

Gets the item index from the Tab.

Parameter Type Description
tabItemId string Item ID is used for getting index from the Tab.

Returns number

getLocalData

Returns the persistence data for component

Returns any

getRootElement

Returns the route element of the component

Returns HTMLElement

handleUnload

Handling unload event to persist data when enable persistence true

Returns void

hideTab

Shows or hides the Tab that is in the specified index.

Parameter Type Description
index number Index value of target item.
value (optional) boolean Based on this Boolean value, item will be hide (false) or show (true). By default, value is true.

Returns void

refresh

Refresh the tab component

Returns void

refreshActiveTab

To refresh the active tab contents.

Returns void

refreshActiveTabBorder

To refresh the active tab indicator.

Returns void

removeEventListener

Removes the handler from the given event listener.

Parameter Type Description
eventName string A String that specifies the name of the event to remove
handler Function Specifies the function to remove

Returns void

removeTab

Removes the items in the Tab from the specified index.

Parameter Type Description
index number Index of target item that is going to be removed.

Returns void

select

Specifies the index or HTMLElement to select an item from the Tab.

Parameter Type Description
args number | HTEle Index or DOM element is used for selecting an item from the Tab.
event (optional) Event An event which takes place in DOM.

Returns void

Inject

Dynamically injects the required modules to the component.

Parameter Type Description
moduleList Function[] ?

Returns void

Events

added

EmitType<AddEventArgs>

The event will be fired after adding the item to the Tab.

adding

EmitType<AddEventArgs>

The event will be fired before adding the item to the Tab.

created

EmitType<Event>

The event will be fired once the component rendering is completed.

destroyed

EmitType<Event>

The event will be fired when the component gets destroyed.

dragged

EmitType<DragEventArgs>

The event will be fired after dropping the Tab item

dragging

EmitType<DragEventArgs>

The event will be fired while dragging the Tab item

onDragStart

EmitType<DragEventArgs>

The event will be fired before dragging the item from Tab

removed

EmitType<RemoveEventArgs>

The event will be fired after removing the item from the Tab.

removing

EmitType<RemoveEventArgs>

The event will be fired before removing the item from the Tab.

selected

EmitType<SelectEventArgs>

The event will be fired after the item gets selected.

selecting

EmitType<SelectingEventArgs>

The event will be fired before the item gets selected.