- Visible tabs
- Adding contextual tabs
- Selected tabs
- Methods
Contact Support
Ribbon contextual tabs
21 Mar 202424 minutes to read
The Ribbon Contextual tabs are similar to the Ribbon tabs that are displayed on demand based on their needs, such as an image or a table tabs. It supports adding all built-in and custom ribbon items to perform specific actions.
Visible tabs
You can utilize the visible property to control the visibility of each contextual tab.
Adding contextual tabs
You can utilize the RibbonContextualTabsDirective
to add contextual tabs in the Ribbon where you can add multiple tabs based on your needs.
import * as React from "react";
import * as ReactDom from "react-dom";
import { RibbonComponent, RibbonTabsDirective, RibbonTabDirective, RibbonCollectionsDirective, RibbonCollectionDirective, RibbonGroupsDirective, RibbonGroupDirective, RibbonItemsDirective, RibbonItemDirective, RibbonItemSize, RibbonContextualTab, RibbonContextualTabsDirective, RibbonContextualTabDirective, Inject } from "@syncfusion/ej2-react-ribbon";
function App() {
return (
<RibbonComponent id='ribbon'>
<RibbonTabsDirective>
<RibbonTabDirective header='Home'>
<RibbonGroupsDirective>
<RibbonGroupDirective header="Clipboard" id="clipboardGroup" groupIconCss="e-icons e-paste" showLauncherIcon={true}>
<RibbonCollectionsDirective>
<RibbonCollectionDirective>
<RibbonItemsDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
</RibbonItemsDirective>
</RibbonCollectionDirective>
</RibbonCollectionsDirective>
</RibbonGroupDirective>
</RibbonGroupsDirective>
</RibbonTabDirective>
</RibbonTabsDirective>
<RibbonContextualTabsDirective>
<RibbonContextualTabDirective visible={true} >
<RibbonTabsDirective>
<RibbonTabDirective header='Shape Format' id="ShapeFormat">
<RibbonGroupsDirective>
<RibbonGroupDirective header="Text decoration" showLauncherIcon={true}>
<RibbonCollectionsDirective>
<RibbonCollectionDirective>
<RibbonItemsDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
</RibbonItemsDirective>
</RibbonCollectionDirective>
</RibbonCollectionsDirective>
</RibbonGroupDirective>
<RibbonGroupDirective header="Accessibility">
<RibbonCollectionsDirective>
<RibbonCollectionDirective>
<RibbonItemsDirective>
<RibbonItemDirective type="Button" allowedSizes={RibbonItemSize.Large} buttonSettings=>
</RibbonItemDirective>
</RibbonItemsDirective>
</RibbonCollectionDirective>
</RibbonCollectionsDirective>
</RibbonGroupDirective>
<RibbonGroupDirective header="Arrange" showLauncherIcon={true}>
<RibbonCollectionsDirective>
<RibbonCollectionDirective>
<RibbonItemsDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
</RibbonItemsDirective>
</RibbonCollectionDirective>
</RibbonCollectionsDirective>
</RibbonGroupDirective>
</RibbonGroupsDirective>
</RibbonTabDirective>
</RibbonTabsDirective>
</RibbonContextualTabDirective>
</RibbonContextualTabsDirective>
<Inject services={[RibbonContextualTab]} />
</RibbonComponent>
);
}
export default App;
ReactDom.render(<App />, document.getElementById("element"));
import * as React from "react";
import * as ReactDom from "react-dom";
import { RibbonComponent, RibbonTabsDirective, RibbonTabDirective, RibbonCollectionsDirective, RibbonCollectionDirective, RibbonGroupsDirective, RibbonGroupDirective, RibbonItemsDirective, RibbonItemDirective, RibbonItemSize, RibbonContextualTab, RibbonContextualTabsDirective, RibbonContextualTabDirective, Inject } from "@syncfusion/ej2-react-ribbon";
function App() {
return (
<RibbonComponent id='ribbon'>
<RibbonTabsDirective>
<RibbonTabDirective header='Home'>
<RibbonGroupsDirective>
<RibbonGroupDirective header="Clipboard" id="clipboardGroup" groupIconCss="e-icons e-paste" showLauncherIcon={true}>
<RibbonCollectionsDirective>
<RibbonCollectionDirective>
<RibbonItemsDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
</RibbonItemsDirective>
</RibbonCollectionDirective>
</RibbonCollectionsDirective>
</RibbonGroupDirective>
</RibbonGroupsDirective>
</RibbonTabDirective>
</RibbonTabsDirective>
<RibbonContextualTabsDirective>
<RibbonContextualTabDirective visible={true} >
<RibbonTabsDirective>
<RibbonTabDirective header='Shape Format' id="ShapeFormat">
<RibbonGroupsDirective>
<RibbonGroupDirective header="Text decoration" showLauncherIcon={true}>
<RibbonCollectionsDirective>
<RibbonCollectionDirective>
<RibbonItemsDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
</RibbonItemsDirective>
</RibbonCollectionDirective>
</RibbonCollectionsDirective>
</RibbonGroupDirective>
<RibbonGroupDirective header="Accessibility">
<RibbonCollectionsDirective>
<RibbonCollectionDirective>
<RibbonItemsDirective>
<RibbonItemDirective type="Button" allowedSizes={RibbonItemSize.Large} buttonSettings=>
</RibbonItemDirective>
</RibbonItemsDirective>
</RibbonCollectionDirective>
</RibbonCollectionsDirective>
</RibbonGroupDirective>
<RibbonGroupDirective header="Arrange" showLauncherIcon={true}>
<RibbonCollectionsDirective>
<RibbonCollectionDirective>
<RibbonItemsDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
</RibbonItemsDirective>
</RibbonCollectionDirective>
</RibbonCollectionsDirective>
</RibbonGroupDirective>
</RibbonGroupsDirective>
</RibbonTabDirective>
</RibbonTabsDirective>
</RibbonContextualTabDirective>
</RibbonContextualTabsDirective>
<Inject services={[RibbonContextualTab]} />
</RibbonComponent>
);
}
export default App;
ReactDom.render(<App />, document.getElementById("element"));
/* Represents the styles for loader */
#loader {
color: #008cff;
height: 40px;
left: 45%;
position: absolute;
top: 45%;
width: 30%;
}
Selected tabs
By using the isSelected property you can control the selected state of each contextual tab and indicates which tab is currently active.
import * as React from "react";
import * as ReactDom from "react-dom";
import { RibbonComponent, RibbonTabsDirective, RibbonTabDirective, RibbonCollectionsDirective, RibbonCollectionDirective, RibbonGroupsDirective, RibbonGroupDirective, RibbonItemsDirective, RibbonItemDirective, RibbonContextualTab, RibbonContextualTabsDirective, RibbonContextualTabDirective, Inject } from "@syncfusion/ej2-react-ribbon";
function App() {
return (
<RibbonComponent id='ribbon'>
<RibbonTabsDirective>
<RibbonTabDirective header='Home'>
<RibbonGroupsDirective>
<RibbonGroupDirective header="Clipboard" id="clipboardGroup" groupIconCss="e-icons e-paste" showLauncherIcon={true}>
<RibbonCollectionsDirective>
<RibbonCollectionDirective>
<RibbonItemsDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
</RibbonItemsDirective>
</RibbonCollectionDirective>
</RibbonCollectionsDirective>
</RibbonGroupDirective>
</RibbonGroupsDirective>
</RibbonTabDirective>
</RibbonTabsDirective>
<RibbonContextualTabsDirective>
<RibbonContextualTabDirective visible={true} isSelected={true}>
<RibbonTabsDirective>
<RibbonTabDirective header='Styles'>
<RibbonGroupsDirective>
<RibbonGroupDirective header="Style" showLauncherIcon={true}>
<RibbonCollectionsDirective>
<RibbonCollectionDirective>
<RibbonItemsDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
</RibbonItemsDirective>
</RibbonCollectionDirective>
</RibbonCollectionsDirective>
</RibbonGroupDirective>
</RibbonGroupsDirective>
</RibbonTabDirective>
</RibbonTabsDirective>
</RibbonContextualTabDirective>
</RibbonContextualTabsDirective>
<Inject services={[RibbonContextualTab]} />
</RibbonComponent>
);
}
export default App;
ReactDom.render(<App />, document.getElementById("element"));
import * as React from "react";
import * as ReactDom from "react-dom";
import { RibbonComponent, RibbonTabsDirective, RibbonTabDirective, RibbonCollectionsDirective, RibbonCollectionDirective, RibbonGroupsDirective, RibbonGroupDirective, RibbonItemsDirective, RibbonItemDirective, RibbonContextualTab, RibbonContextualTabsDirective, RibbonContextualTabDirective, Inject } from "@syncfusion/ej2-react-ribbon";
function App() {
return (
<RibbonComponent id='ribbon'>
<RibbonTabsDirective>
<RibbonTabDirective header='Home'>
<RibbonGroupsDirective>
<RibbonGroupDirective header="Clipboard" id="clipboardGroup" groupIconCss="e-icons e-paste" showLauncherIcon={true}>
<RibbonCollectionsDirective>
<RibbonCollectionDirective>
<RibbonItemsDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
</RibbonItemsDirective>
</RibbonCollectionDirective>
</RibbonCollectionsDirective>
</RibbonGroupDirective>
</RibbonGroupsDirective>
</RibbonTabDirective>
</RibbonTabsDirective>
<RibbonContextualTabsDirective>
<RibbonContextualTabDirective visible={true} isSelected={true}>
<RibbonTabsDirective>
<RibbonTabDirective header='Styles'>
<RibbonGroupsDirective>
<RibbonGroupDirective header="Style" showLauncherIcon={true}>
<RibbonCollectionsDirective>
<RibbonCollectionDirective>
<RibbonItemsDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
</RibbonItemsDirective>
</RibbonCollectionDirective>
</RibbonCollectionsDirective>
</RibbonGroupDirective>
</RibbonGroupsDirective>
</RibbonTabDirective>
</RibbonTabsDirective>
</RibbonContextualTabDirective>
</RibbonContextualTabsDirective>
<Inject services={[RibbonContextualTab]} />
</RibbonComponent>
);
}
export default App;
ReactDom.render(<App />, document.getElementById("element"));
/* Represents the styles for loader */
#loader {
color: #008cff;
height: 40px;
left: 45%;
position: absolute;
top: 45%;
width: 30%;
}
Methods
Show tab
You can use the showTab method to make the specific Contextual tab visible in the Ribbon.
Hide tab
You can use the hideTab method to hide specific Contextual tab in the Ribbon.
import * as React from "react";
import * as ReactDom from "react-dom";
import { RibbonComponent, RibbonTabsDirective, RibbonTabDirective, RibbonCollectionsDirective, RibbonCollectionDirective, RibbonGroupsDirective, RibbonGroupDirective, RibbonItemsDirective, RibbonItemDirective, RibbonContextualTab, RibbonContextualTabsDirective, RibbonContextualTabDirective, Inject } from "@syncfusion/ej2-react-ribbon";
import { useRef } from 'react';
function App() {
let ribbonObj = useRef(null);
const showContextualTab = () => {
ribbonObj.current.showTab('ArrangeView', true);
}
const hideContextualTab = () => {
ribbonObj.current.hideTab('ArrangeView', true);
}
return (
<div>
<button className="e-btn" id="show-contextual" onClick={showContextualTab}> Show tab </button>
<button className="e-btn" id="hide-contextual" onClick={hideContextualTab}> Hide tab </button>
<RibbonComponent id='ribbon' ref={ribbonObj}>
<RibbonTabsDirective>
<RibbonTabDirective header='Home'>
<RibbonGroupsDirective>
<RibbonGroupDirective header="Clipboard" id="clipboardGroup" groupIconCss="e-icons e-paste" showLauncherIcon={true}>
<RibbonCollectionsDirective>
<RibbonCollectionDirective>
<RibbonItemsDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
</RibbonItemsDirective>
</RibbonCollectionDirective>
</RibbonCollectionsDirective>
</RibbonGroupDirective>
</RibbonGroupsDirective>
</RibbonTabDirective>
</RibbonTabsDirective>
<RibbonContextualTabsDirective>
<RibbonContextualTabDirective>
<RibbonTabsDirective>
<RibbonTabDirective id="ArrangeView" header="Arrange & View">
<RibbonGroupsDirective>
<RibbonGroupDirective header="Arrange" showLauncherIcon={true}>
<RibbonCollectionsDirective>
<RibbonCollectionDirective>
<RibbonItemsDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
</RibbonItemsDirective>
</RibbonCollectionDirective>
</RibbonCollectionsDirective>
</RibbonGroupDirective>
</RibbonGroupsDirective>
</RibbonTabDirective>
</RibbonTabsDirective>
</RibbonContextualTabDirective>
</RibbonContextualTabsDirective>
<Inject services={[RibbonContextualTab]} />
</RibbonComponent>
</div>
);
}
export default App;
ReactDom.render(<App />, document.getElementById("element"));
import * as React from "react";
import * as ReactDom from "react-dom";
import { RibbonComponent, RibbonTabsDirective, RibbonTabDirective, RibbonCollectionsDirective, RibbonCollectionDirective, RibbonGroupsDirective, RibbonGroupDirective, RibbonItemsDirective, RibbonItemDirective, RibbonContextualTab, RibbonContextualTabsDirective, RibbonContextualTabDirective, Inject } from "@syncfusion/ej2-react-ribbon";
import { useRef } from 'react';
function App() {
let ribbonObj = useRef<RibbonComponent>(null);
const showContextualTab = () => {
ribbonObj.current.showTab('ArrangeView', true);
}
const hideContextualTab = () => {
ribbonObj.current.hideTab('ArrangeView', true);
}
return (
<div>
<button className="e-btn" id="show-contextual" onClick={showContextualTab}> Show tab </button>
<button className="e-btn" id="hide-contextual" onClick={hideContextualTab}> Hide tab </button>
<RibbonComponent id='ribbon' ref={ribbonObj}>
<RibbonTabsDirective>
<RibbonTabDirective header='Home'>
<RibbonGroupsDirective>
<RibbonGroupDirective header="Clipboard" id="clipboardGroup" groupIconCss="e-icons e-paste" showLauncherIcon={true}>
<RibbonCollectionsDirective>
<RibbonCollectionDirective>
<RibbonItemsDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
</RibbonItemsDirective>
</RibbonCollectionDirective>
</RibbonCollectionsDirective>
</RibbonGroupDirective>
</RibbonGroupsDirective>
</RibbonTabDirective>
</RibbonTabsDirective>
<RibbonContextualTabsDirective>
<RibbonContextualTabDirective>
<RibbonTabsDirective>
<RibbonTabDirective id="ArrangeView" header="Arrange & View">
<RibbonGroupsDirective>
<RibbonGroupDirective header="Arrange" showLauncherIcon={true}>
<RibbonCollectionsDirective>
<RibbonCollectionDirective>
<RibbonItemsDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
<RibbonItemDirective type="Button" buttonSettings=>
</RibbonItemDirective>
</RibbonItemsDirective>
</RibbonCollectionDirective>
</RibbonCollectionsDirective>
</RibbonGroupDirective>
</RibbonGroupsDirective>
</RibbonTabDirective>
</RibbonTabsDirective>
</RibbonContextualTabDirective>
</RibbonContextualTabsDirective>
<Inject services={[RibbonContextualTab]} />
</RibbonComponent>
</div>
);
}
export default App;
ReactDom.render(<App />, document.getElementById("element"));
/* Represents the styles for loader */
#loader {
color: #008cff;
height: 40px;
left: 45%;
position: absolute;
top: 45%;
width: 30%;
}
#ribbon {
margin-top: 20px;
}