| Class name | Type | Description |
|---|---|---|
collapse |
Component | Collapse |
collapse-title |
Part | Title part |
collapse-content |
Part | Content part |
collapse-arrow |
Modifier | Adds arrow icon |
collapse-plus |
Modifier | Adds plus/minus icon |
collapse-open |
Modifier | Force open |
collapse-close |
Modifier | Force close |
Accordion uses the same style as the collapse component but it works with radio inputs or details elements. You can control which item to be open by checking/unchecking the hidden radio input or setting the open attribute on details element.
All radio inputs with the same name work together and only one of them can be open at a time. If you have more than one set of accordion items on a page, use different names for the radio inputs or details elements on each set.
If you want the collapsed content to be searcheable in browser use the Accordion using details
<div class="collapse bg-base-100 border border-base-300">
<input type="radio" name="my-accordion-1" checked="checked" />
<div class="collapse-title font-semibold">How do I create an account?</div>
<div class="collapse-content text-sm">Click the "Sign Up" button in the top right corner and follow the registration process.</div>
</div>
<div class="collapse bg-base-100 border border-base-300">
<input type="radio" name="my-accordion-1" />
<div class="collapse-title font-semibold">I forgot my password. What should I do?</div>
<div class="collapse-content text-sm">Click on "Forgot Password" on the login page and follow the instructions sent to your email.</div>
</div>
<div class="collapse bg-base-100 border border-base-300">
<input type="radio" name="my-accordion-1" />
<div class="collapse-title font-semibold">How do I update my profile information?</div>
<div class="collapse-content text-sm">Go to "My Account" settings and select "Edit Profile" to make changes.</div>
</div>
Component.fragment([
Collapse(
[
input(type: InputType.radio, name: 'my-accordion-1', checked: true),
CollapseTitle([Component.text('How do I create an account?')], classes: 'font-semibold'),
CollapseContent(
[
Component.text('Click the "Sign Up" button in the top right corner and follow the registration process.'),
],
classes: 'text-sm',
),
],
classes: 'bg-base-100 border border-base-300',
),
Collapse(
[
input(type: InputType.radio, name: 'my-accordion-1'),
CollapseTitle(
[Component.text('I forgot my password. What should I do?')],
classes: 'font-semibold',
),
CollapseContent(
[
Component.text('Click on "Forgot Password" on the login page and follow the instructions sent to your email.'),
],
classes: 'text-sm',
),
],
classes: 'bg-base-100 border border-base-300',
),
Collapse(
[
input(type: InputType.radio, name: 'my-accordion-1'),
CollapseTitle(
[Component.text('How do I update my profile information?')],
classes: 'font-semibold',
),
CollapseContent(
[
Component.text('Go to "My Account" settings and select "Edit Profile" to make changes.'),
],
classes: 'text-sm',
),
],
classes: 'bg-base-100 border border-base-300',
),
]);
How do I create an account?
I forgot my password. What should I do?
How do I update my profile information?
<details class="collapse bg-base-100 border border-base-300" name="my-accordion-det-1" open="">
<summary class="collapse-title font-semibold">How do I create an account?</summary>
<div class="collapse-content text-sm">Click the "Sign Up" button in the top right corner and follow the registration process.</div>
</details>
<details class="collapse bg-base-100 border border-base-300" name="my-accordion-det-1">
<summary class="collapse-title font-semibold">I forgot my password. What should I do?</summary>
<div class="collapse-content text-sm">Click on "Forgot Password" on the login page and follow the instructions sent to your email.</div>
</details>
<details class="collapse bg-base-100 border border-base-300" name="my-accordion-det-1">
<summary class="collapse-title font-semibold">How do I update my profile information?</summary>
<div class="collapse-content text-sm">Go to "My Account" settings and select "Edit Profile" to make changes.</div>
</details>
Component.fragment([
details(
[
summary(
[Component.text('How do I create an account?')],
classes: 'collapse-title font-semibold',
),
CollapseContent(
[
Component.text('Click the "Sign Up" button in the top right corner and follow the registration process.'),
],
classes: 'text-sm',
),
],
classes: 'collapse bg-base-100 border border-base-300',
open: true,
attributes: {'name': 'my-accordion-det-1'},
),
details(
[
summary(
[Component.text('I forgot my password. What should I do?')],
classes: 'collapse-title font-semibold',
),
CollapseContent(
[
Component.text('Click on "Forgot Password" on the login page and follow the instructions sent to your email.'),
],
classes: 'text-sm',
),
],
classes: 'collapse bg-base-100 border border-base-300',
attributes: {'name': 'my-accordion-det-1'},
),
details(
[
summary(
[Component.text('How do I update my profile information?')],
classes: 'collapse-title font-semibold',
),
CollapseContent(
[
Component.text('Go to "My Account" settings and select "Edit Profile" to make changes.'),
],
classes: 'text-sm',
),
],
classes: 'collapse bg-base-100 border border-base-300',
attributes: {'name': 'my-accordion-det-1'},
),
]);
<div class="collapse collapse-arrow bg-base-100 border border-base-300">
<input type="radio" name="my-accordion-2" checked="checked" />
<div class="collapse-title font-semibold">How do I create an account?</div>
<div class="collapse-content text-sm">Click the "Sign Up" button in the top right corner and follow the registration process.</div>
</div>
<div class="collapse collapse-arrow bg-base-100 border border-base-300">
<input type="radio" name="my-accordion-2" />
<div class="collapse-title font-semibold">I forgot my password. What should I do?</div>
<div class="collapse-content text-sm">Click on "Forgot Password" on the login page and follow the instructions sent to your email.</div>
</div>
<div class="collapse collapse-arrow bg-base-100 border border-base-300">
<input type="radio" name="my-accordion-2" />
<div class="collapse-title font-semibold">How do I update my profile information?</div>
<div class="collapse-content text-sm">Go to "My Account" settings and select "Edit Profile" to make changes.</div>
</div>
Component.fragment([
Collapse(
[
input(type: InputType.radio, name: 'my-accordion-2', checked: true),
CollapseTitle([Component.text('How do I create an account?')], classes: 'font-semibold'),
CollapseContent(
[
Component.text('Click the "Sign Up" button in the top right corner and follow the registration process.'),
],
classes: 'text-sm',
),
],
classes: 'bg-base-100 border border-base-300',
modifier: CollapseModifier.arrow,
),
Collapse(
[
input(type: InputType.radio, name: 'my-accordion-2'),
CollapseTitle(
[Component.text('I forgot my password. What should I do?')],
classes: 'font-semibold',
),
CollapseContent(
[
Component.text('Click on "Forgot Password" on the login page and follow the instructions sent to your email.'),
],
classes: 'text-sm',
),
],
classes: 'bg-base-100 border border-base-300',
modifier: CollapseModifier.arrow,
),
Collapse(
[
input(type: InputType.radio, name: 'my-accordion-2'),
CollapseTitle(
[Component.text('How do I update my profile information?')],
classes: 'font-semibold',
),
CollapseContent(
[
Component.text('Go to "My Account" settings and select "Edit Profile" to make changes.'),
],
classes: 'text-sm',
),
],
classes: 'bg-base-100 border border-base-300',
modifier: CollapseModifier.arrow,
),
]);
<div class="collapse collapse-plus bg-base-100 border border-base-300">
<input type="radio" name="my-accordion-3" checked="checked" />
<div class="collapse-title font-semibold">How do I create an account?</div>
<div class="collapse-content text-sm">Click the "Sign Up" button in the top right corner and follow the registration process.</div>
</div>
<div class="collapse collapse-plus bg-base-100 border border-base-300">
<input type="radio" name="my-accordion-3" />
<div class="collapse-title font-semibold">I forgot my password. What should I do?</div>
<div class="collapse-content text-sm">Click on "Forgot Password" on the login page and follow the instructions sent to your email.</div>
</div>
<div class="collapse collapse-plus bg-base-100 border border-base-300">
<input type="radio" name="my-accordion-3" />
<div class="collapse-title font-semibold">How do I update my profile information?</div>
<div class="collapse-content text-sm">Go to "My Account" settings and select "Edit Profile" to make changes.</div>
</div>
Component.fragment([
Collapse(
[
input(type: InputType.radio, name: 'my-accordion-3', checked: true),
CollapseTitle([Component.text('How do I create an account?')], classes: 'font-semibold'),
CollapseContent(
[
Component.text('Click the "Sign Up" button in the top right corner and follow the registration process.'),
],
classes: 'text-sm',
),
],
classes: 'bg-base-100 border border-base-300',
modifier: CollapseModifier.plus,
),
Collapse(
[
input(type: InputType.radio, name: 'my-accordion-3'),
CollapseTitle(
[Component.text('I forgot my password. What should I do?')],
classes: 'font-semibold',
),
CollapseContent(
[
Component.text('Click on "Forgot Password" on the login page and follow the instructions sent to your email.'),
],
classes: 'text-sm',
),
],
classes: 'bg-base-100 border border-base-300',
modifier: CollapseModifier.plus,
),
Collapse(
[
input(type: InputType.radio, name: 'my-accordion-3'),
CollapseTitle(
[Component.text('How do I update my profile information?')],
classes: 'font-semibold',
),
CollapseContent(
[
Component.text('Go to "My Account" settings and select "Edit Profile" to make changes.'),
],
classes: 'text-sm',
),
],
classes: 'bg-base-100 border border-base-300',
modifier: CollapseModifier.plus,
),
]);
<div class="join join-vertical bg-base-100">
<div class="collapse collapse-arrow join-item border-base-300 border">
<input type="radio" name="my-accordion-4" checked="checked" />
<div class="collapse-title font-semibold">How do I create an account?</div>
<div class="collapse-content text-sm">Click the "Sign Up" button in the top right corner and follow the registration process.</div>
</div>
<div class="collapse collapse-arrow join-item border-base-300 border">
<input type="radio" name="my-accordion-4" />
<div class="collapse-title font-semibold">I forgot my password. What should I do?</div>
<div class="collapse-content text-sm">Click on "Forgot Password" on the login page and follow the instructions sent to your email.</div>
</div>
<div class="collapse collapse-arrow join-item border-base-300 border">
<input type="radio" name="my-accordion-4" />
<div class="collapse-title font-semibold">How do I update my profile information?</div>
<div class="collapse-content text-sm">Go to "My Account" settings and select "Edit Profile" to make changes.</div>
</div>
</div>
Join(
[
Collapse(
[
input(type: InputType.radio, name: 'my-accordion-4', checked: true),
CollapseTitle([Component.text('How do I create an account?')], classes: 'font-semibold'),
CollapseContent(
[
Component.text('Click the "Sign Up" button in the top right corner and follow the registration process.'),
],
classes: 'text-sm',
),
],
classes: 'join-item border-base-300 border',
modifier: CollapseModifier.arrow,
),
Collapse(
[
input(type: InputType.radio, name: 'my-accordion-4'),
CollapseTitle(
[Component.text('I forgot my password. What should I do?')],
classes: 'font-semibold',
),
CollapseContent(
[
Component.text('Click on "Forgot Password" on the login page and follow the instructions sent to your email.'),
],
classes: 'text-sm',
),
],
classes: 'join-item border-base-300 border',
modifier: CollapseModifier.arrow,
),
Collapse(
[
input(type: InputType.radio, name: 'my-accordion-4'),
CollapseTitle(
[Component.text('How do I update my profile information?')],
classes: 'font-semibold',
),
CollapseContent(
[
Component.text('Go to "My Account" settings and select "Edit Profile" to make changes.'),
],
classes: 'text-sm',
),
],
classes: 'join-item border-base-300 border',
modifier: CollapseModifier.arrow,
),
],
classes: 'bg-base-100',
direction: JoinDirection.vertical,
);