You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

layout-accordion.asciidoc 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. ---
  2. title: Accordion
  3. order: 10
  4. layout: page
  5. ---
  6. [[layout.accordion]]
  7. = Accordion
  8. ifdef::web[]
  9. [.sampler]
  10. image:{live-demo-image}[alt="Live Demo", link="http://demo.vaadin.com/sampler/#ui/structure/accordion"]
  11. endif::web[]
  12. [classname]#Accordion# is a multicomponent container similar to
  13. [classname]#TabSheet#, except that the "tabs" are arranged vertically. Clicking
  14. on a tab opens its contained component in the space between the tab and the next
  15. one. You can use an [classname]#Accordion# identically to a
  16. [classname]#TabSheet#, which it actually inherits. See
  17. <<layout-tabsheet#layout.tabsheet,"TabSheet">>
  18. for more information.
  19. The following example shows how you can create a simple accordion. As the
  20. [classname]#Accordion# is rather naked alone, we put it inside a Panel that acts
  21. as its caption and provides it a border.
  22. [source, java]
  23. ----
  24. // Create the accordion
  25. Accordion accordion = new Accordion();
  26. // Create the first tab, specify caption when adding
  27. Layout tab1 = new VerticalLayout(); // Wrap in a layout
  28. tab1.addComponent(new Image(null, // No component caption
  29. new ThemeResource("img/planets/Mercury.jpg")));
  30. accordion.addTab(tab1, "Mercury",
  31. new ThemeResource("img/planets/Mercury_symbol.png"));
  32. // This tab gets its caption from the component caption
  33. Component tab2 = new Image("Venus",
  34. new ThemeResource("img/planets/Venus.jpg"));
  35. accordion.addTab(tab2).setIcon(
  36. new ThemeResource("img/planets/Venus_symbol.png"));
  37. // And so forth the other tabs...
  38. String[] tabs = {"Earth", "Mars", "Jupiter", "Saturn"};
  39. for (String caption: tabs) {
  40. String basename = "img/planets/" + caption;
  41. VerticalLayout tab = new VerticalLayout();
  42. tab.addComponent(new Image(null,
  43. new ThemeResource(basename + ".jpg")));
  44. accordion.addTab(tab, caption,
  45. new ThemeResource(basename + "_symbol.png"));
  46. }
  47. ----
  48. <<figure.accordion.example1>> shows what the example would look like with the
  49. default theme.
  50. [[figure.accordion.example1]]
  51. .An Accordion
  52. image::img/accordion-example1.png[width=40%, scaledwidth=55%]
  53. == CSS Style Rules
  54. [source, css]
  55. ----
  56. .v-accordion {}
  57. .v-accordion-item,
  58. .v-accordion-item-open,
  59. .v-accordion-item-first {}
  60. .v-accordion-item-caption {}
  61. .v-caption {}
  62. .v-accordion-item-content {}
  63. .v-scollable {}
  64. ----
  65. The top-level element of [classname]#Accordion# has the
  66. [literal]#++v-accordion++# style. An [classname]#Accordion# consists of a
  67. sequence of item elements, each of which has a caption element (the tab) and a
  68. content area element.
  69. The selected item (tab) has also the [literal]#++v-accordion-open++# style. The
  70. content area is not shown for the closed items.