With %%collapse you can turn ordered and unordered hierarchical lists and trees into collapsible lists.
The list bullets become clickable buttons to expand or collapse the nested list items. You can also use the keyboard: press Tab/shift-Tab to navigate between the buttons; use Enter or spacebar to toggle the collapse state of the list item.
See also Collapsible Box, Haddock Styles, Accordion.
Usage#
Default rendering
Collasible list
- list item 1
- list item 1.1
- list item 1.1.1
- list item 1.1.2
- list item 1.1
%%collapse * list item 1 ** list item 1.1 *** list item 1.1.1 *** list item 1.1.2 /%
Collasible list
- list item 1
- list item 1.1
- list item 1.1.1
- list item 1.1.2
- list item 1.1
Ordered collapsible lists are initially rendered collapsed.
Default rendering
Collasible list
- list item 1
- list item 1.1
- list item 1.1.1
- list item 1.1.2
- list item 1.1
%%collapse # list item 1 ## list item 1.1 ### list item 1.1.1 ### list item 1.1.2 /%
Collasible list
- list item 1
- list item 1.1
- list item 1.1.1
- list item 1.1.2
- list item 1.1
Note:
- The state of each collapsible item is persisted in a cookie, so when you visit that page later on, the collapsible items are restored to their last-visited state.
- You can delete the collapse cookie for a page in UserPreferences
- The Sidebar has its own collapsible state cookie
- The size of the clickable icon can be increased by changing the font-size of the .collapse-btn element
%%add-css .collapse-btn { font-size: 1.3em; } /%
Mixed UL/OL #
You can mix unordered and ordered lists
Default list
With %%collapse
- Europe
- France
- Paris
- Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec dictum velit eget risus. Fusce ligula. Maecenas vitae velit eget odio pulvinar aliquet. Quisque ultricies mollis lorem. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
- South-Africa
- Belgium
- Brussel (these items are by default collapsed)
- Peulis
- France
- Australia
- Sydney
- Kangeroo
- Huppeldepup
- Sydney
With %%collapse
- Europe
- France
- Paris
- Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec dictum velit eget risus. Fusce ligula. Maecenas vitae velit eget odio pulvinar aliquet. Quisque ultricies mollis lorem. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
- South-Africa
- Belgium
- Brussel (these items are by default collapsed)
- Peulis
- France
- Australia
- Sydney
- Kangeroo
- Huppeldepup
- Sydney
Skipped levels#
Lists can have empty items.
Default list
With %%collapse
- list item 1
- list item 111
- list item 112
- list item 113
- list item 2
- list item 21
- list item 211
- list item 21
%%collapse *list item 1 *** list item 111 *** list item 112 *** list item 113 *list item 2 **list item 21 ***list item 211 /%
With %%collapse
- list item 1
- list item 111
- list item 112
- list item 113
- list item 2
- list item 21
- list item 211
- list item 21
No style#
.list-nostyle hides the bullets
With %%list-nostyle
With %%collapse.list-nostyle
- list item 1
- list item 111
- list item 112
- list item 113
- list item 2
- list item 21
- list item 211
- list item 21
%%collapse.list-nostyle *list item 1 *** list item 111 *** list item 112 *** list item 113 *list item 2 **list item 21 ***list item 211 /%
With %%collapse.list-nostyle
- list item 1
- list item 111
- list item 112
- list item 113
- list item 2
- list item 21
- list item 211
- list item 21
Unstyled#
.list-unstyled removes the indentiation of the list
With %%list-unstyled
With %%collapse.list-unstyled
- list item 1
- list item 111
- list item 112
- list item 113
- list item 2
- list item 21
- list item 211
- list item 21
%%collapse.list-unstyled *list item 1 *** list item 111 *** list item 112 *** list item 113 *list item 2 **list item 21 ***list item 211 /%
With %%collapse.list-unstyled
- list item 1
- list item 111
- list item 112
- list item 113
- list item 2
- list item 21
- list item 211
- list item 21
List Group#
With %%list-group
With %%collapse.list-group
- list item 1
- list item 111
- list item 112
- list item 113
- list item 2
- list item 21
- list item 211
- list item 21
%%collapse.list-group *list item 1 *** list item 111 *** list item 112 *** list item 113 *list item 2 **list item 21 ***list item 211 /%
With %%collapse.list-group
- list item 1
- list item 111
- list item 112
- list item 113
- list item 2
- list item 21
- list item 211
- list item 21
Tree#
Default
With %%collapse.tree
- list item 1
- list item 111
- list item 112
- list item 113
- list item 2
- list item 21
- list item 211
- list item 21
%%collapse.tree *list item 1 *** list item 111 *** list item 112 *** list item 113 *list item 2 **list item 21 ***list item 211 /%
With %%collapse.tree
- list item 1
- list item 111
- list item 112
- list item 113
- list item 2
- list item 21
- list item 211
- list item 21
Category.Style, Haddock Template, Haddock Components, Collapsible Box