How can I help you?
Items in EJ2 TypeScript Ribbon control
3 Feb 202624 minutes to read
The Ribbon control renders various built-in items based on the type property of a ribbon-item. By default, this property is set to Button, which renders a standard Button item.
Built-in Items
Render the built-in Ribbon items by using the items property. Specify the desired item by setting its type property.
The following table describes the available built-in items and their functions:
| Built-in Ribbon Item | Action |
|---|---|
| Button | Renders a clickable button. |
| CheckBox | Renders a checkbox for binary selection. |
| DropDown | Renders a dropdown button with a popup list. |
| SplitButton | Renders a button with a primary action and a secondary dropdown list. |
| ComboBox | Renders a combo box for selection from a list of options. |
| ColorPicker | Renders a color picker for color selection. |
| GroupButton | Renders a group of related buttons. |
Button items
To render a Button item, set the type property to Button. You can customize its appearance and behavior using the RibbonButtonSettingsModel, which includes options like iconCss, content, and isToggle.
Toggle button
The isToggle property can be used to define whether the button act as a toggle button or not. By default, the value is false.
import { Ribbon, RibbonTabModel, RibbonItemType } from "@syncfusion/ej2-ribbon";
let tabs: RibbonTabModel[] = [{
header: "Home",
groups: [{
header: "Clipboard",
collections: [
{
items: [{
type: RibbonItemType.Button,
buttonSettings: {
content: "Cut",
iconCss: "e-icons e-cut",
isToggle: true
}
}]
}]
}]
}];
let ribbon: Ribbon = new Ribbon({
tabs: tabs
});
ribbon.appendTo("#ribbon");CheckBox Items
To render a CheckBox, set the type property to CheckBox. Customize it using the RibbonCheckBoxSettingsModel, which provides options for label, labelPosition, and checked state.
Checkbox state
You can use the checked property to handle the checked or unchecked state. By default, the value is false.
import { Ribbon, RibbonTabModel, RibbonItemType } from "@syncfusion/ej2-ribbon";
let tabs: RibbonTabModel[] = [{
header: "Home",
groups: [{
header: "View",
collections: [
{
items: [{
type: RibbonItemType.CheckBox,
checkBoxSettings: {
label: "Ruler",
checked: true
}
}]
}]
}]
}];
let ribbon: Ribbon = new Ribbon({ tabs: tabs });
ribbon.appendTo("#ribbon");Defining label
You can use the label property to add a caption for the CheckBox. The label position can be set Before or After, by using the labelPosition property. By default, the labelPosition is After.
import { Ribbon, RibbonTabModel, RibbonItemType } from "@syncfusion/ej2-ribbon";
let tabs: RibbonTabModel[] = [{
header: "Home",
groups: [{
header: "View",
collections: [
{
items: [{
type: RibbonItemType.CheckBox,
checkBoxSettings: {
label: "Ruler",
labelPosition: "Before"
}
}]
}]
}]
}];
let ribbon: Ribbon = new Ribbon({ tabs: tabs });
ribbon.appendTo("#ribbon");DropDown Button Items
To render a DropDownButton, set the type property to DropDown. Customize it using the RibbonDropDownSettingsModel, which includes items, iconCss, content, and a target for the popup content.
Target
The target property specifies the element selector for the content to be displayed in the DropDownButton popup.
import { Ribbon, RibbonTabModel, RibbonItemType } from "@syncfusion/ej2-ribbon";
import { ListView } from "@syncfusion/ej2-lists";
let tabs: RibbonTabModel[] = [
{
header: "Home",
groups: [
{
header: "Illustrations",
collections: [
{
items: [
{
type: RibbonItemType.DropDown,
dropDownSettings: {
content: "Picture",
iconCss: "e-icons e-image",
target: "#pictureList"
}
},
],
}
]
}
]
}
];
let list: ListView = new ListView({
showHeader: true,
headerTitle: 'Insert Picture From',
dataSource: ['This device', 'Stock Images', 'Online Images']
});
list.appendTo('#pictureList');
let ribbon: Ribbon = new Ribbon({
tabs: tabs
});
ribbon.appendTo("#ribbon");Customize dropdown button item
Apply a custom CSS class to style dropdown items using the beforeItemRender event.
The following sample showcases how to customize a specific dropdown item.
import { Ribbon, RibbonTabModel, RibbonItemType } from "@syncfusion/ej2-ribbon";
import { MenuEventArgs } from "@syncfusion/ej2-splitbuttons";
let tabs: RibbonTabModel[] = [
{
header: "Insert",
groups: [
{
header: "Tables",
collections: [
{
items: [
{
type: RibbonItemType.DropDown,
id: 'dropdownItem',
dropDownSettings: {
iconCss: 'e-icons e-table',
content: 'Table',
items: [
{ text: 'Insert Table' },
{ text: 'Draw Table' },
{ text: 'Convert Table' },
{ text: 'Excel SpreadSheet' },
],
beforeItemRender:(args: MenuEventArgs) => {
if (args.item.text === 'Insert Table') {
args.element.classList.add("e-custom-class");
}
}
},
},
],
}
]
}
]
}
];
let ribbon: Ribbon = new Ribbon({
tabs: tabs
});
ribbon.appendTo("#ribbon");<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js"></script>
<title>Essential JS 2 - Ribbon</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<meta name="description" content="Essential JS 2" />
<meta name="author" content="Syncfusion" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-base/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-buttons/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-popups/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-splitbuttons/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-inputs/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-lists/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-dropdowns/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-navigations/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-ribbon/styles/tailwind3.css" rel="stylesheet" />
<!--system js reference and configuration-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<style>
.e-custom-class {
color: green;
}
</style>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>LOADING....</div>
<div id='container'>
<div id="ribbon"></div>
</div>
</body>
</html>Create dropdown popup on demand
Set the createPopupOnClick property to true to create the popup only when the dropdown is opened, optimizing performance.
import { Ribbon, RibbonTabModel, RibbonItemType } from "@syncfusion/ej2-ribbon";
let tabs: RibbonTabModel[] = [
{
header: "Insert",
groups: [
{
header: "Tables",
collections: [
{
items: [
{
type: RibbonItemType.DropDown,
id: 'dropdownItem',
dropDownSettings: {
iconCss: 'e-icons e-table',
content: 'Table',
items: [
{ text: 'Insert Table' },
{ text: 'Draw Table' },
{ text: 'Convert Table' },
{ text: 'Excel SpreadSheet' },
],
createPopupOnClick: true
},
},
],
}
]
}
]
}
];
let ribbon: Ribbon = new Ribbon({
tabs: tabs
});
ribbon.appendTo("#ribbon");<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js"></script>
<title>Essential JS 2 - Ribbon</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<meta name="description" content="Essential JS 2" />
<meta name="author" content="Syncfusion" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-base/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-buttons/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-popups/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-splitbuttons/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-inputs/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-lists/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-dropdowns/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-navigations/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-ribbon/styles/tailwind3.css" rel="stylesheet" />
<!--system js reference and configuration-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>LOADING....</div>
<div id='container'>
<div id="ribbon"></div>
</div>
</body>
</html>Split button items
To render a SplitButton, set the type property to SplitButton. Customize it with the RibbonSplitButtonSettingsModel, which provides options like iconCss, items, and target.
Target
The target property specifies the element selector to be displayed in the SplitButton popup.
import { Ribbon, RibbonTabModel, RibbonItemType } from "@syncfusion/ej2-ribbon";
import { ListView } from "@syncfusion/ej2-lists";
let tabs: RibbonTabModel[] = [
{
header: "Home",
groups: [
{
header: "Illustrations",
collections: [
{
items: [
{
type: RibbonItemType.SplitButton,
splitButtonSettings: {
content: "Picture",
iconCss: "e-icons e-image",
target: "#pictureList"
}
},
],
}
]
}
]
}
];
let list: ListView = new ListView({
showHeader: true,
headerTitle: 'Insert Picture From',
dataSource: ['This device', 'Stock Images', 'Online Images']
});
list.appendTo('#pictureList');
let ribbon: Ribbon = new Ribbon({
tabs: tabs
});
ribbon.appendTo("#ribbon");<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js"></script>
<title>Essential JS 2 - Ribbon</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<meta name="description" content="Essential JS 2" />
<meta name="author" content="Syncfusion" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-base/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-buttons/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-popups/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-splitbuttons/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-inputs/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-lists/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-dropdowns/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-navigations/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-ribbon/styles/tailwind3.css" rel="stylesheet" />
<!--system js reference and configuration-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>LOADING....</div>
<div id='container'>
<div id="ribbon"></div>
<div id="pictureList"></div>
</div>
</body>
</html>ComboBox Items
To render a ComboBox item, set the type property to ComboBox. You can configure it using the RibbonComboBoxSettingsModel, which provides options such as allowFiltering, autoFill, index, sortOrder and more.
Filtering
You can use the allowFiltering property to filter the data items. The filtering operation is initiated automatically, as soon as you start typing characters. If no match is found the value of the noRecordsTemplate property will be displayed. By default, the value is false.
import { Ribbon, RibbonTabModel, RibbonItemType } from "@syncfusion/ej2-ribbon";
let fontStyle: string[] = ["Algerian", "Arial", "Calibri", "Cambria", "Cambria Math", "Courier New", "Candara", "Georgia"];
let tabs: RibbonTabModel[] = [{
header: "Home",
groups: [{
header: "Font",
collections: [
{
items: [{
type: RibbonItemType.ComboBox,
comboBoxSettings: {
dataSource: fontStyle,
index: 3,
allowFiltering: true
}
}]
}]
}]
}];
let ribbon: Ribbon = new Ribbon({ tabs: tabs });
ribbon.appendTo("#ribbon");Index
You can use the index property to get or set the selected item in the combobox.
import { Ribbon, RibbonTabModel, RibbonItemType } from "@syncfusion/ej2-ribbon";
let fontStyle: string[] = ["Algerian", "Arial", "Calibri", "Cambria", "Cambria Math", "Courier New", "Candara", "Georgia"];
let tabs: RibbonTabModel[] = [{
header: "Home",
groups: [{
header: "Font",
collections: [
{
items: [{
type: RibbonItemType.ComboBox,
comboBoxSettings: {
dataSource: fontStyle,
index: 3
}
}]
}]
}]
}];
let ribbon: Ribbon = new Ribbon({ tabs: tabs });
ribbon.appendTo("#ribbon");SortOrder
You can use the sortOrder property to specify the order in which the DataSource should be sorted.
| `None` | The data source is not sorted. |
| `Ascending` | The data source is sorted in ascending order. |
| `Descending` | The data source is sorted in descending order. |
import { Ribbon, RibbonTabModel, RibbonItemType } from "@syncfusion/ej2-ribbon";
let fontStyle: string[] = ["Algerian", "Arial", "Calibri", "Cambria", "Cambria Math", "Courier New", "Candara", "Georgia"];
let tabs: RibbonTabModel[] = [{
header: "Home",
groups: [{
header: "Font",
collections: [
{
items: [{
type: RibbonItemType.ComboBox,
comboBoxSettings: {
dataSource: fontStyle,
sortOrder: "Descending"
}
}]
}]
}]
}];
let ribbon: Ribbon = new Ribbon({ tabs: tabs });
ribbon.appendTo("#ribbon");<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js"></script>
<title>Essential JS 2 - Ribbon</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<meta name="description" content="Essential JS 2" />
<meta name="author" content="Syncfusion" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-base/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-buttons/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-popups/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-splitbuttons/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-inputs/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-lists/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-dropdowns/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-navigations/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-ribbon/styles/tailwind3.css" rel="stylesheet" />
<!--system js reference and configuration-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>LOADING....</div>
<div id='container'>
<div id="ribbon"></div>
</div>
</body>
</html>Colorpicker items
To render a ColorPicker, set the type property to ColorPicker. Customize it using the RibbonColorPickerSettingsModel, which includes properties like value, columns, and showButtons.
Value
You can use the value property to specify the color value. The value should be specified as Hex code.
import { Ribbon, RibbonTabModel, RibbonItemType, RibbonColorPicker } from "@syncfusion/ej2-ribbon";
Ribbon.Inject(RibbonColorPicker);
let tabs: RibbonTabModel[] = [{
header: "Home",
groups: [{
header: "Font",
collections: [
{
items: [{
type: RibbonItemType.ColorPicker,
colorPickerSettings: {
value: "#123456"
}
}]
}]
}]
}];
let ribbon: Ribbon = new Ribbon({ tabs: tabs });
ribbon.appendTo("#ribbon");<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js"></script>
<title>Essential JS 2 - Ribbon</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<meta name="description" content="Essential JS 2" />
<meta name="author" content="Syncfusion" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-base/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-buttons/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-popups/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-splitbuttons/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-inputs/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-lists/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-dropdowns/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-navigations/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-ribbon/styles/tailwind3.css" rel="stylesheet" />
<!--system js reference and configuration-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>LOADING....</div>
<div id='container'>
<div id="ribbon"></div>
</div>
</body>
</html>Groupbutton items
To render a GroupButton, set the type property to GroupButton. Configure its items and selection behavior using the RibbonGroupButtonSettingsModel.
Items
You can render the groupbutton items by using items property. You can also customize the groupbutton items through RibbonGroupButtonItemModel, which provides options such as content, iconCss, selected and more.
Item content
You can use the content property to define the text content for the groupbutton.
import { Ribbon, RibbonTabModel, RibbonItemType, RibbonItemSize } from "@syncfusion/ej2-ribbon";
let tabs: RibbonTabModel[] = [{
header: "Home",
groups: [{
header: "Paragraph",
collections: [
{
items: [{
type: RibbonItemType.GroupButton,
allowedSizes: RibbonItemSize.Small,
groupButtonSettings: {
items: [{
iconCss: 'e-icons e-align-left',
content: 'Align Left'
},
{
iconCss: 'e-icons e-align-center',
content: 'Align Center'
},
{
iconCss: 'e-icons e-align-right',
content: 'Align Right'
},
{
iconCss: 'e-icons e-justify',
content: 'Justify'
}]
}
}]
}]
}]
}];
let ribbon: Ribbon = new Ribbon({ tabs: tabs });
ribbon.appendTo("#ribbon");Icon only
You can use the iconCss property to customize the groupbutton icon. If the iconCss property is not defined, the groupbutton will not be rendered.
import { Ribbon, RibbonTabModel, RibbonItemType, RibbonItemSize } from "@syncfusion/ej2-ribbon";
let tabs: RibbonTabModel[] = [{
header: "Home",
groups: [{
header: "Paragraph",
collections: [
{
items: [{
type: RibbonItemType.GroupButton,
allowedSizes: RibbonItemSize.Small,
groupButtonSettings: {
items: [{
iconCss: 'e-icons e-align-left'
},
{
iconCss: 'e-icons e-align-center'
},
{
iconCss: 'e-icons e-align-right'
},
{
iconCss: 'e-icons e-justify'
}]
}
}]
}]
}]
}];
let ribbon: Ribbon = new Ribbon({ tabs: tabs });
ribbon.appendTo("#ribbon");<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js"></script>
<title>Essential JS 2 - Ribbon</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<meta name="description" content="Essential JS 2" />
<meta name="author" content="Syncfusion" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-base/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-buttons/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-popups/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-splitbuttons/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-inputs/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-lists/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-dropdowns/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-navigations/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-ribbon/styles/tailwind3.css" rel="stylesheet" />
<!--system js reference and configuration-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>LOADING....</div>
<div id='container'>
<div id="ribbon"></div>
</div>
</body>
</html>Selection
You can use the selected property to select the groupbutton item initally. When set to true, the button will be selected. By default the selected property is false.
import { Ribbon, RibbonTabModel, RibbonItemType, RibbonItemSize } from "@syncfusion/ej2-ribbon";
let tabs: RibbonTabModel[] = [{
header: "Home",
groups: [{
header: "Paragraph",
collections: [
{
items: [{
type: RibbonItemType.GroupButton,
allowedSizes: RibbonItemSize.Small,
groupButtonSettings: {
items: [{
iconCss: 'e-icons e-align-left',
content: 'Align Left'
},
{
iconCss: 'e-icons e-align-center',
content: 'Align Center',
selected: true
},
{
iconCss: 'e-icons e-align-right',
content: 'Align Right'
},
{
iconCss: 'e-icons e-justify',
content: 'Justify'
}]
}
}]
}]
}]
}];
let ribbon: Ribbon = new Ribbon({ tabs: tabs });
ribbon.appendTo("#ribbon");<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js"></script>
<title>Essential JS 2 - Ribbon</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<meta name="description" content="Essential JS 2" />
<meta name="author" content="Syncfusion" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-base/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-buttons/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-popups/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-splitbuttons/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-inputs/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-lists/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-dropdowns/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-navigations/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-ribbon/styles/tailwind3.css" rel="stylesheet" />
<!--system js reference and configuration-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>LOADING....</div>
<div id='container'>
<div id="ribbon"></div>
</div>
</body>
</html>Single selection
You can set the selection property value as RibbonGroupButtonSelection.Single to make one selection at a time. It automatically deselects the previous choice when a different item is clicked.
import { Ribbon, RibbonTabModel, RibbonItemType, RibbonGroupButtonSelection, RibbonItemSize } from "@syncfusion/ej2-ribbon";
let tabs: RibbonTabModel[] = [{
header: "Home",
groups: [{
header: "Paragraph",
collections: [
{
items: [{
type: RibbonItemType.GroupButton,
allowedSizes: RibbonItemSize.Small,
groupButtonSettings: {
selection: RibbonGroupButtonSelection.Single,
items: [{
iconCss: 'e-icons e-align-left',
content: 'Align Left'
},
{
iconCss: 'e-icons e-align-center',
content: 'Align Center',
selected: true
},
{
iconCss: 'e-icons e-align-right',
content: 'Align Right'
},
{
iconCss: 'e-icons e-justify',
content: 'Justify'
}]
}
}]
}]
}]
}];
let ribbon: Ribbon = new Ribbon({ tabs: tabs });
ribbon.appendTo("#ribbon");<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js"></script>
<title>Essential JS 2 - Ribbon</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<meta name="description" content="Essential JS 2" />
<meta name="author" content="Syncfusion" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-base/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-buttons/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-popups/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-splitbuttons/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-inputs/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-lists/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-dropdowns/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-navigations/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-ribbon/styles/tailwind3.css" rel="stylesheet" />
<!--system js reference and configuration-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>LOADING....</div>
<div id='container'>
<div id="ribbon"></div>
</div>
</body>
</html>Multiple selection
You can set the selection property value as RibbonGroupButtonSelection.Multiple to select more than one button at a time. Users can select a button one by one to select multiple buttons.
import { Ribbon, RibbonTabModel, RibbonItemType, RibbonGroupButtonSelection, RibbonItemSize } from "@syncfusion/ej2-ribbon";
let tabs: RibbonTabModel[] = [{
header: "Home",
groups: [{
header: "Paragraph",
collections: [
{
items: [{
type: RibbonItemType.GroupButton,
allowedSizes: RibbonItemSize.Small,
groupButtonSettings: {
selection: RibbonGroupButtonSelection.Multiple,
items: [{
iconCss: 'e-icons e-bold',
content: 'Bold'
},
{
iconCss: 'e-icons e-italic',
content: 'Italic',
selected: true
},
{
iconCss: 'e-icons e-underline',
content: 'Underline'
},
{
iconCss: 'e-icons e-strikethrough',
selected: true,
content: 'Strikethrough'
}]
}
}]
}]
}]
}];
let ribbon: Ribbon = new Ribbon({ tabs: tabs });
ribbon.appendTo("#ribbon");<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js"></script>
<title>Essential JS 2 - Ribbon</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<meta name="description" content="Essential JS 2" />
<meta name="author" content="Syncfusion" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-base/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-buttons/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-popups/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-splitbuttons/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-inputs/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-lists/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-dropdowns/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-navigations/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-ribbon/styles/tailwind3.css" rel="stylesheet" />
<!--system js reference and configuration-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>LOADING....</div>
<div id='container'>
<div id="ribbon"></div>
</div>
</body>
</html>Groupbutton in simplified mode layout
In simplified mode, the groupbutton will be rendered as a dropdownbutton. The dropdownbutton icon will be updated based on the button item selected. The initial button icon will be the set, if none of the buttons are selected.
import { Ribbon, RibbonTabModel, RibbonItemType, RibbonGroupButtonSelection, RibbonItemSize } from "@syncfusion/ej2-ribbon";
let tabs: RibbonTabModel[] = [{
header: "Home",
groups: [{
header: "Paragraph",
collections: [
{
items: [{
type: RibbonItemType.GroupButton,
allowedSizes: RibbonItemSize.Small,
groupButtonSettings: {
selection: RibbonGroupButtonSelection.Single,
items: [{
iconCss: 'e-icons e-align-left',
content: 'Align Left'
},
{
iconCss: 'e-icons e-align-center',
content: 'Align Center',
selected: true
},
{
iconCss: 'e-icons e-align-right',
content: 'Align Right'
},
{
iconCss: 'e-icons e-justify',
content: 'Justify'
}]
}
}]
}]
}]
}];
let ribbon: Ribbon = new Ribbon({ tabs: tabs, activeLayout: 'Simplified' });
ribbon.appendTo("#ribbon");<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js"></script>
<title>Essential JS 2 - Ribbon</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<meta name="description" content="Essential JS 2" />
<meta name="author" content="Syncfusion" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-base/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-buttons/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-popups/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-splitbuttons/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-inputs/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-lists/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-dropdowns/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-navigations/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-ribbon/styles/tailwind3.css" rel="stylesheet" />
<!--system js reference and configuration-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>LOADING....</div>
<div id='container'>
<div id="ribbon"></div>
</div>
</body>
</html>Custom items
To create custom Ribbon items, set the type property to Template. This allows you to render any HTML content or non-built-in components, offering maximum flexibility.
import { Ribbon, RibbonTabModel, RibbonItemType } from "@syncfusion/ej2-ribbon";
let tabs: RibbonTabModel[] = [{
header: "Home",
groups: [
{
header: 'Templates',
isCollapsible: false,
collections: [
{
items: [
{
type: RibbonItemType.Template,
itemTemplate: '#customItem'
}
],
},
],
}, {
header: "Multimedia",
collections: [
{
items: [{
type: RibbonItemType.Template,
itemTemplate: "#itemTemplate"
}]
}]
}]
}];
let ribbon: Ribbon = new Ribbon({ tabs: tabs });
ribbon.appendTo("#ribbon");<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js"></script>
<title>Essential JS 2 - Ribbon</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<meta name="description" content="Essential JS 2" />
<meta name="author" content="Syncfusion" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-base/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-buttons/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-popups/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-splitbuttons/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-inputs/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-lists/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-dropdowns/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-navigations/styles/tailwind3.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/32.2.3/ej2-ribbon/styles/tailwind3.css" rel="stylesheet" />
<!--system js reference and configuration-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<style>
.ribbonTemplate {
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
}
.ribbonTemplate.Large {
flex-direction: column;
}
.ribbonTemplate.Large .e-icons {
font-size: 35px;
}
.ribbonTemplate.Medium .e-icons,
.ribbonTemplate.Small .e-icons{
font-size: 20px;
margin: 15px 5px;
}
.ribbonTemplate.Small .text {
display:none;
}
.custom-template input {
margin-left: 10px;
width: 100px;
}
.custom-template.Medium {
display: flex;
align-items: center;
}
.custom-template.Medium input {
height: 14px;
margin-right: 10px;
}
</style>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>LOADING....</div>
<div id='container'>
<div id="ribbon"></div>
</div>
<script type="text/x-jsrender" id="itemTemplate">
<span class="ribbonTemplate ${activeSize}">
<span class="e-icons e-video"></span>
<span class="text">Video</span>
</span>
</script>
<script type="text/x-jsrender" id="customItem">
<div class="custom-template ${activeSize}">
<label for="fname">First name:</label>
<input type="text" id="fname" name="fname">
<br><br>
<label for="lname">Last name:</label>
<input type="text" id="lname" name="lname">
</div>
</script>
</body>
</html>Items display Mode
Use the displayOptions property to control in which Ribbon layouts an item appears.
| Option | Description |
|---|---|
Auto |
(Default) The item is displayed in all layouts. |
Classic |
The item is displayed only in the classic layout. |
Simplified |
The item is displayed only in the simplified layout. |
Overflow |
The item is displayed only in the overflow popup. |
Display items in Classic only
To display the items only in the classic layout group, set the mode as DisplayMode.Classic in the displayOptions property.
import { Ribbon, RibbonTabModel, RibbonItemType, DisplayMode } from "@syncfusion/ej2-ribbon";
let tabs: RibbonTabModel[] = [{
header: "Home",
groups: [{
header: "Font",
collections: [
{
items: [{
type: RibbonItemType.Button,
displayOptions: DisplayMode.Classic,
buttonSettings: {
content: "Cut",
iconCss: "e-icons e-cut"
}
}]
}]
}]
}];
let ribbon: Ribbon = new Ribbon({ tabs: tabs });
ribbon.appendTo("#ribbon");Display items in Simplified only
To display the items only in the simplified layout group, set the mode as DisplayMode.Simplified in the displayOptions property.
import { Ribbon, RibbonTabModel, RibbonItemType, DisplayMode } from "@syncfusion/ej2-ribbon";
let tabs: RibbonTabModel[] = [{
header: "Home",
groups: [{
header: "Font",
collections: [
{
items: [{
type: RibbonItemType.Button,
displayOptions: DisplayMode.Simplified,
buttonSettings: {
content: "Cut",
iconCss: "e-icons e-cut"
}
}]
}]
}]
}];
let ribbon: Ribbon = new Ribbon({ tabs: tabs });
ribbon.appendTo("#ribbon");Display items in Overflow popup only
To display the items only in the overflow, set the mode as DisplayMode.Overflow in the displayOptions property.
import { Ribbon, RibbonTabModel, RibbonItemType, DisplayMode } from "@syncfusion/ej2-ribbon";
let tabs: RibbonTabModel[] = [{
header: "Home",
groups: [{
header: "Font",
collections: [
{
items: [{
type: RibbonItemType.Button,
displayOptions: DisplayMode.Overflow,
buttonSettings: {
content: "Cut",
iconCss: "e-icons e-cut"
}
}]
}]
}]
}];
let ribbon: Ribbon = new Ribbon({ tabs: tabs });
ribbon.appendTo("#ribbon");Enable or disable items
Use the disabled property to enable or disable a Ribbon item. When set to true, the item becomes non-interactive.
import { Ribbon, RibbonTabModel, RibbonItemType } from "@syncfusion/ej2-ribbon";
let tabs: RibbonTabModel[] = [{
header: "Home",
groups: [{
header: "Clipboard",
collections: [
{
items: [{
type: RibbonItemType.Button,
disabled: true,
buttonSettings: {
content: "Cut",
iconCss: "e-icons e-cut"
}
},
{
type: RibbonItemType.CheckBox,
disabled: true,
checkBoxSettings: {
label: "Ruler",
checked: true
}
},
{
type: RibbonItemType.DropDown,
disabled: true,
dropDownSettings: {
content: "Table",
iconCss: "e-icons e-table",
}
},
{
type: RibbonItemType.SplitButton,
disabled: true,
splitButtonSettings: {
content: "Table",
iconCss: "e-icons e-table"
}
}]
}]
}]
}];
let ribbon: Ribbon = new Ribbon({
tabs: tabs
});
ribbon.appendTo("#ribbon");