Skip to main content

Button

The Button control displays a button with a text label and an optional icon. A button can have two states and show a badge with a number, for example, to count new messages.

Toolbar button with an icon, label, and a number badge in DHTMLX Suite

Related sample: Toolbar. Button

Add a button​

Use the add() method of TreeCollection to add a button to a toolbar:

toolbar.data.add({
type:"button", value:"Best button"
});

Properties​

Check the list of properties that you can set in the configuration object of a Button control.

Add an icon​

Use the icon property to add an icon to a button:

{
type:"button", value:"Done",
icon:"dxi dxi-check"
}

Add a badge with a number​

Set the count property to add a badge with a number to a button, for example, to show the number of new messages:

{
type:"button", value:"Done",
icon:"dxi dxi-check",
count:10
}

Add HTML content​

Use the html property to add custom HTML content to a button:

{
type: "button",
html: "<div className='user-button'><img src='../avatars/Avatar.jpg'/></div>",
}

Related sample: Toolbar. Item HTML content

Show and hide a button​

The show() and hide() methods show and hide a button by its ID:

toolbar.show(id);
toolbar.hide(id);

Related sample: Toolbar. Hide / show items

Enable and disable a button​

The enable() and disable() methods enable and disable a button by its ID:

toolbar.enable(id);
toolbar.disable(id);

Related sample: Toolbar. Enable / disable items

Add a tooltip​

Use the tooltip property to add a tooltip to a button:

{
type:"button",
value:"Click",
tooltip:"Click me and find out why"
}

Related sample: Toolbar. Tooltips