DevExtreme React - Overview
The Accordion widget contains several panels displayed one under another. These panels can be collapsed or expanded by an end user, which makes this widget very useful for presenting information in a limited amount of space.
The following code adds a simple Accordion to your page. Note that each data source object contains the title field, whose value goes to the title of the panel.
JavaScript
HTML
- var accordionData = [{
- title: "Personal Data",
- firstName: "John",
- lastName: "Smith",
- birthYear: 1986
- }, {
- title: "Contacts",
- phone: "(555)555-5555",
- email: "John.Smith@example.com"
- }, {
- title: "Address",
- state: "CA",
- city: "San Francisco",
- street: "Stanford Ave"
- }];
- $(function () {
- $("#accordionContainer").dxAccordion({
- dataSource: accordionData,
- itemTemplate: function (itemData, itemIndex, itemElement) {
- for (var field in itemData) {
- itemElement.append("<p>" + field + ": " + itemData[field] + "</p>");
- }
- }
- });
- });
- <div id="accordionContainer"></div>
See Also
Feel free to share topic-related thoughts here.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
Thank you for the feedback!
If you have technical questions, please create a support ticket in the DevExpress Support Center.