An accordion layout layouts panel titles vertically, only one of the panel contents is visible at a time.

  • Fluent
  • Declarative

    AccordionLayout
                   .builder()
                   .panels(List.of(
                          new AccordionPanel("Panel 1", new Text("Panel 1")),
                          new AccordionPanel("Panel 2", new Text("Panel 2")),
                          new AccordionPanel("Panel 3", new Text("Panel 3"))
                   ))
                   .build()

    @AccordionLayout
    List panels = List.of(
        new Text("Panel 1"),
        new Text("Panel 2"),
        new Text("Panel 3")
      );

or


    @AccordionLayout
    class Container {
        
      Object panel1 = new Text("Panel 1");
      @AcoordionPanel(active=true)
      Object panel2 = new Text("Panel 2");
      Object panel3 = new Text("Panel 3");
      
    }

Available properties

This is the list of available properties for a accordion layout:

PropertyDescriptionNotes
idid for this component
cssClasseslist of css classescontent of the css attribute
styleinline style attributescontent of the style attribute
fullWidthshortcut to set width:100%true/false
variantone of filled, small, reverse

And this is the list of available properties for a accordion panel:

PropertyDescriptionNotes
activetrue/falseonly 1 panel is active at a time
disabledtrue/false

You can see a full explanation of those properties at https://vaadin.com/docs/latest/components/accordion