spz-accordion
布局
Layouts
跳转到“Layouts”Usage
跳转到“Usage”The spz-accordion
allows you to display collapsible and expandable content sections.
- An
spz-accordion
accepts one or more<section>
elements as its direct children. - Each
<section>
must contain two direct children:- The first child is the header of the section.
- The second child is the expandable or collapsible content.
You can expand or collapse the content of a <section>
by click
or tap
on the section header.
Animated Collapse and Expand
跳转到“Animated Collapse and Expand”You can use a animate
attribute to animate expand and collapse the content. You can add a expanded
attribute to <section>
when you want the section to expand by default.
<spz-accordion layout="container" animate>
<section>
<h3>Header 1</h3>
<div>Content 1</div>
</section>
<section expanded>
<h3>Header 2</h3>
<div>Content 2</div>
</section>
</spz-accordion>
Attributes
跳转到“Attributes”animate
跳转到“animate”If this attribute is present, there will be a default animation effect when the content of section expands or collapses.
expanded
跳转到“expanded”If a <section>
has an expanded
attribute, its content expands by default.
expand-single-section
跳转到“expand-single-section”If this attribute is present, only one of the <section>
elements can be expanded at a time.
Actions
跳转到“Actions”toggle
跳转到“toggle”To toggle the content of a section to expand or collapse.
Parameter | Description | Type | Default | Required |
---|---|---|---|---|
section | <section> element’s id |
string | - | Yes |
expand
跳转到“expand”To expand the content of a section.
Parameter | Description | Type | Default | Required |
---|---|---|---|---|
section | <section> element’s id |
string | - | Yes |
collapse
跳转到“collapse”To collapse the content of a section.
Parameter | Description | Type | Default | Required |
---|---|---|---|---|
section | <section> element’s id |
string | - | Yes |
<spz-accordion id="accordion" layout="container" animate>
<section id="specified-section">
<h3>Header 1</h3>
<div>Content 1</div>
</section>
<section>
<h3>Header 2</h3>
<div>Content 2</div>
</section>
</spz-accordion>
<button type="button" @tap="accordion.toggle(section='specified-section')">Toggle</button>
<button type="button" @tap="accordion.expand(section='specified-section')">Expand</button>
<button type="button" @tap="accordion.collapse(section='specified-section')">Collapse</button>
Events
跳转到“Events”expand
跳转到“expand”Be automatically triggered when the element has any <section>
that is expanded.
collapse
跳转到“collapse”Be automatically triggered when the element has any <section>
that is collapsed.
<div id="text">Expanded OR Collapsed</div>
<spz-accordion
layout="container"
@expand="text.toggleClass(class='expand', force=true);"
@collapse="text.toggleClass(class='collapse', force=true);"
>
<section>
<h3>Header 1</h3>
<div>Content 1</div>
</section>
</spz-accordion>