Collapsible Widgetversion added: 1.0
Description: Creates a collapsible block of content
To create a collapsible block of content, create a container and add the data-role="collapsible" attribute. Using data-content-theme attribute allows you to set a theme for the content of the collapsible.
Directly inside this container, add any header (H1-H6) or legend element. The framework will style the header to look like a clickable button and add a "+" icon to the left to indicate it's expandable.
After the header, add any HTML markup you want to be collapsible. The framework will wrap this markup in a container that will be hidden/shown when the heading is clicked.
By default, the content will be collapsed.
1
2
3
4
|
|
This code will create a collapsible widget like this:
Expanding collapsibles on load
To expand the content when the page loads, add the data-collapsed="false"
attribute to the wrapper.
1
|
|
This code will create a collapsible widget like this:
Non-inset collapsibles
By default collapsibles have an inset appearance. To make them full width without corner styling add the data-inset="false"
attribute to the element.
1
|
|
This code will create a non-inset collapsible:
Mini collapsibles
For a more compact version that is useful in toolbars and tight spaces, add the data-mini="true"
attribute to the element to create a mini version.
1
|
|
This code will create a mini collapsible widget:
Custom icons
Collapsible headings’ default icons can be overridden by using the data-collapsed-icon
and data-expanded-icon
attributes. In the below case, data-collapsed-icon="arrow-r"
and data-expanded-icon="arrow-d"
.
Icon positioning
Collapsible headings’ default icon positioning can be overridden by using the data-iconpos
attribute. In the below case, data-iconpos="right"
.
Theming collapsible content
Collapsible content is minimally styled - we add only a bit of margin between the bar and content, and the header adopts the default theme styles of the container it sits within.
To provide a stronger visual connection between the collapsible header and content, add the data-content-theme
attribute to the wrapper and specify a theme swatch letter. This will apply the swatch's border and flat background color (not the gradient) to the content block and changes the corner rounding to square off the bottom of the header and round the bottom of the content block instead to visually group these elements.
1
2
3
4
|
|
Theming collapsible headers
To set the theme on a collapsible header button, add the data-theme
attribute to the wrapper and specify a swatch letter. Note that you can mix and match swatch letters between the header and content with these theme attributes.
1
2
3
4
|
|
Nested Collapsibles
Collapsibles can be nested inside each other if needed. In this example, we're setting the content theme to provide clearer visual connection between the levels.
Collapsible sets (accordions)
It's possible to combine multiple collapsibles into a grouped set that acts like an accordion widget.
Options
collapseCueText
" click to collapse contents"
This option is also exposed as a data attribute: data-collapse-cue-text=" collapse with a click"
.
Initialize the collapsible with the collapseCueText
option specified:
1
2
3
|
|
Get or set the collapseCueText
option, after initialization:
1
2
3
4
5
|
|
collapsed
true
This option is also exposed as a data attribute: data-collapsed="false"
.
Initialize the collapsible with the collapsed
option specified:
1
2
3
|
|
Get or set the collapsed
option, after initialization:
1
2
3
4
5
|
|
collapsedIcon
"plus"
This option is also exposed as a data attribute: data-collapsed-icon="arrow-r"
.
- String: The name of the icon you wish to use.
-
Boolean: In addition to an icon name, you can also set this option to
false
. In that case, the collapsible will not have an icon in either the expanded or collapsed state. Adddata-collapsed-icon="false"
to the collapsible widget to set the option tofalse
via the data attribute.
Initialize the collapsible with the collapsedIcon
option specified:
1
2
3
|
|
Get or set the collapsedIcon
option, after initialization:
1
2
3
4
5
|
|
corners
true
This option is also exposed as a data attribute: data-corners="false"
.
Initialize the collapsible with the corners
option specified:
1
2
3
|
|
Get or set the corners
option, after initialization:
1
2
3
4
5
|
|
expandCueText
" click to expand contents"
This option is also exposed as a data attribute: data-expand-cue-text=" expand with a click"
.
Initialize the collapsible with the expandCueText
option specified:
1
2
3
|
|
Get or set the expandCueText
option, after initialization:
1
2
3
4
5
|
|
expandedIcon
"minus"
This option is also exposed as a data attribute: data-expanded-icon="arrow-d"
.
Initialize the collapsible with the expandedIcon
option specified:
1
2
3
|
|
Get or set the expandedIcon
option, after initialization:
1
2
3
4
5
|
|
heading
"h1,h2,h3,h4,h5,h6,legend"
Initialize the collapsible with the heading
option specified:
1
2
3
|
|
Get or set the heading
option, after initialization:
1
2
3
4
5
|
|
iconpos
"left"
Possible values: left, right, top, bottom, none, notext.
This option is also exposed as a data attribute: data-iconpos="right"
.
Initialize the collapsible with the iconpos
option specified:
1
2
3
|
|
Get or set the iconpos
option, after initialization:
1
2
3
4
5
|
|
initSelector
":jqmData(role='collapsible')"
1
2
3
|
|
inset
true
This option is also exposed as a data attribute: data-inset="false"
.
Initialize the collapsible with the inset
option specified:
1
2
3
|
|
Get or set the inset
option, after initialization:
1
2
3
4
5
|
|
mini
false
This option is also exposed as a data attribute: data-mini="true"
.
Initialize the collapsible with the mini
option specified:
1
2
3
|
|
Get or set the mini
option, after initialization:
1
2
3
4
5
|
|
theme
null, inherited from parent
Possible values: swatch letter (a-z).
This option is also exposed as a data attribute: data-theme="a"
.
Initialize the collapsible with the theme
option specified:
1
2
3
|
|
Get or set the theme
option, after initialization:
1
2
3
4
5
|
|
Methods
Events
collapse( event, ui )Type: collapsiblecollapse
Note: The ui
object is empty but included for consistency with other events.
Initialize the collapsible with the collapse callback specified:
1
2
3
|
|
Bind an event listener to the collapsiblecollapse event:
1
|
|
create( event, ui )Type: collapsiblecreate
Note: The ui
object is empty but included for consistency with other events.
Initialize the collapsible with the create callback specified:
1
2
3
|
|
Bind an event listener to the collapsiblecreate event:
1
|
|
expand( event, ui )Type: collapsibleexpand
Note: The ui
object is empty but included for consistency with other events.
Initialize the collapsible with the expand callback specified:
1
2
3
|
|
Bind an event listener to the collapsibleexpand event:
1
|
|
Example:
A basic example of a collapsible content block.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
|