Your search did not match any results.
Button Group

Button Group

Documentation

ButtonGroup is a widget that displays a set of toggleable buttons and allows a user to select one or several of them. This demo illustrates how to configure the widget to enable single and multiple selection.

Copy to CodePen
Apply
Reset
window.onload = function() { var viewModel = { singleButtonGroupOptions: { items: alignments, keyExpr: "alignment", stylingMode: "outlined", selectedItemKeys: ["left"], onItemClick: function(e){ DevExpress.ui.notify({ message: 'The "' + e.itemData.hint + '" button was clicked', width: 320 }, "success", 1000); } }, multipleButtonGroupOptions: { items: fontStyles, keyExpr: "style", stylingMode: "outlined", selectionMode: "multiple", onItemClick: function(e){ DevExpress.ui.notify({ message: 'The "' + e.itemData.hint + '" button was clicked', width: 320 }, "success", 1000); } }, singleStylingModeButtonGroupOptions: { items: alignments, keyExpr: "alignment", stylingMode: "text", selectedItemKeys: ["left"], onItemClick: function(e){ DevExpress.ui.notify({ message: 'The "' + e.itemData.hint + '" button was clicked', width: 320 }, "success", 1000); } }, multipleStylingModeButtonGroupOptions: { items: fontStyles, keyExpr: "style", stylingMode: "text", selectionMode: "multiple", onItemClick: function(e){ DevExpress.ui.notify({ message: 'The "' + e.itemData.hint + '" button was clicked', width: 320 }, "success", 1000); } } }; ko.applyBindings(viewModel, document.getElementById("demo")); };
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script>window.jQuery || document.write(decodeURIComponent('%3Cscript src="js/jquery.min.js"%3E%3C/script%3E'))</script> <script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/19.1.6/css/dx.common.css" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/19.1.6/css/dx.light.css" /> <script src="https://cdn3.devexpress.com/jslib/19.1.6/js/dx.all.js"></script> <link rel="stylesheet" type="text/css" href="styles.css" /> <script src="data.js"></script> <script src="index.js"></script> </head> <body class="dx-viewport"> <div class="demo-container"> <div id="demo"> <div class="buttongroups-container"> <div data-bind="dxButtonGroup: singleButtonGroupOptions"></div> <div data-bind="dxButtonGroup: multipleButtonGroupOptions"></div> </div> <div class="buttongroups-container"> <div data-bind="dxButtonGroup: singleStylingModeButtonGroupOptions"></div> <div data-bind="dxButtonGroup: multipleStylingModeButtonGroupOptions"></div> </div> </div> </div> </body> </html>
.buttongroups-container { display: flex; justify-content: center; font-size: 16px; } .buttongroups-container > div { padding: 0 12px; } .buttongroups-container:first-child { margin-top: 120px; margin-bottom: 40px; } #multiple-selection-styling-mode{ border-left-width: 1px; border-left-style: solid; border-color: #dddddd; }
var alignments = [ { icon: "alignleft", alignment: "left", hint: "Align left" }, { icon: "aligncenter", alignment: "center", hint: "Center" }, { icon: "alignright", alignment: "right", hint: "Align right" }, { icon: "alignjustify", alignment: "justify", hint: "Justify" } ]; var fontStyles = [ { icon: "bold", style: "bold", hint: "Bold" }, { icon: "italic", style: "italic", hint: "Italic" }, { icon: "underline", style: "underline", hint: "Underlined" }, { icon: "strike", style: "strike", hint: "Strikethrough" } ];