Search results

ExpandMode

The Accordion supports the two listed types of expand modes while expanding or collapsing the item.

  • Single
  • Multiple

Single

The property enables to expand only one Accordion item at a time. If you expand any new item, the previously expanded one is collapsed and new item changed to expanded state.

You can also choose which accordion pane is expanded state at initial rendering by enabling the expanded property on accordion items.

Source
Preview
index.tsx
import { AccordionComponent, AccordionItemDirective, AccordionItemsDirective  } from '@syncfusion/ej2-react-navigations';
import * as React from 'react';
import * as ReactDOM from "react-dom";

export default class ReactApp extends React.Component<{}, {}> {
  public content0() {
    return <div>
        Microsoft ASP.NET is a set of technologies in the Microsoft .NET Framework for building Web applications and XML Web services.
      </div>;
  }
  public content1() {
    return <div>
        The Model-View-Controller (MVC) architectural pattern separates an application into three main components: the model, the view, and the controller.
      </div>;
  }
  public content2() {
    return <div>
        JavaScript (JS) is an interpreted computer programming language.It was originally implemented as part of web browsers so that client-side scripts could interact with the user, control the browser, communicate asynchronously, and alter the document content that was displayed.
      </div>;
  }
  public render() {
    return (
        <AccordionComponent expandMode='Single'>
            <AccordionItemsDirective>
              <AccordionItemDirective expanded='true' header='ASP.NET' content={this.content0} />
              <AccordionItemDirective header='ASP.NET MVC' content={this.content1} />
              <AccordionItemDirective header='JavaScript' content={this.content2} />
            </AccordionItemsDirective>
        </AccordionComponent>
    );
  }
}
ReactDOM.render(<ReactApp/>, document.getElementById("element"));

Multiple

Default expandMode of the Accordion is Multiple. It enables you to expand more than one Accordion item at a time. Expand/collapse action can also be toggled by clicking on it again. For example, expanded item is collapsed when you click on it again.

Source
Preview
index.tsx
import { AccordionComponent, AccordionItemDirective, AccordionItemsDirective  } from '@syncfusion/ej2-react-navigations';
import * as React from 'react';
import * as ReactDOM from "react-dom";

export default class ReactApp extends React.Component<{}, {}> {
  public content0() {
    return <div>
        Microsoft ASP.NET is a set of technologies in the Microsoft .NET Framework for building Web applications and XML Web services.
      </div>;
  }
  public content1() {
    return <div>
        The Model-View-Controller (MVC) architectural pattern separates an application into three main components: the model, the view, and the controller.
      </div>;
  }
  public content2() {
    return <div>
        JavaScript (JS) is an interpreted computer programming language.It was originally implemented as part of web browsers so that client-side scripts could interact with the user, control the browser, communicate asynchronously, and alter the document content that was displayed.
      </div>;
  }
  public render() {
    return (
        <AccordionComponent expandMode='Multiple'>
            <AccordionItemsDirective>
              <AccordionItemDirective expanded='true' header='ASP.NET' content={this.content0} />
              <AccordionItemDirective header='ASP.NET MVC' content={this.content1} />
              <AccordionItemDirective header='JavaScript' content={this.content2} />
            </AccordionItemsDirective>
        </AccordionComponent>
    );
  }
}
ReactDOM.render(<ReactApp/>, document.getElementById("element"));

See Also