Collapse & Accordion
DCollapse is driven by a hidden checkbox that daisy lays over the title row —
toggling is pure CSS. Bind DAccordion stacks items on one shared radio group, so exclusivity is native.
A
<DCollapse Title="What is this?" Icon="DaisyCollapseIcon.Chevron" Class="bg-base-200">
<p class="opacity-80">A <c>collapse collapse-arrow</c> with checkbox, title and content — daisyUI does the rest.</p>
</DCollapse>
<DCollapse Title="Plus icon" Icon="DaisyCollapseIcon.Plus" Class="bg-base-200">
<p class="opacity-80"><c>collapse-plus</c> swaps the chevron for a plus/minus indicator.</p>
</DCollapse>Open state is now owned by Blazor.
closed
<DCollapse Title="Toggle me" @bind-Open="_open" Class="bg-base-200">
<p class="opacity-80">Open state is now owned by Blazor.</p>
</DCollapse>
<p class="mt-3 text-sm">
<span class="badge @(_open ? "badge-success" : "badge-ghost")">@(_open ? "open" : "closed")</span>
<button class="btn btn-sm btn-ghost ml-3" @onclick="() => _open = !_open">
Toggle from code
</button>
</p>
@code {
private bool _open;
}Free shipping on orders over $50.
30-day no-questions returns.
Two years, parts and labour.
Active: shipping
Radio accordions cannot close the open item by clicking its own title — that is daisy's
native behaviour. Use a standalone DCollapse +
<DAccordion @bind-ActiveKey="_activeKey">
<DAccordionItem Key="shipping" Title="Shipping">
<p class="opacity-80">Free shipping on orders over $50.</p>
</DAccordionItem>
<DAccordionItem Key="returns" Title="Returns" Icon="DaisyCollapseIcon.Plus">
<p class="opacity-80">30-day no-questions returns.</p>
</DAccordionItem>
<DAccordionItem Key="warranty" Title="Warranty">
<p class="opacity-80">Two years, parts and labour.</p>
</DAccordionItem>
</DAccordion>
<p class="mt-3 text-sm">
Active: <span class="badge badge-info badge-outline">@(_activeKey ?? "none")</span>
</p>
<p class="mt-1 text-xs opacity-60">
Radio accordions cannot close the open item by clicking its own title — that is daisy's
native behaviour. Use a standalone <code>DCollapse</code> + <c>@bind-Open</c> when closing matters.
</p>
@code {
private string? _activeKey = "shipping";
}API
Parameters
| Name | Type | Default | Binding | Description |
|---|---|---|---|---|
| Open | bool | False | @bind-Open | Open state — use with @bind-Open . Only managed when bound. |
| Title | string | — | — | Plain-text title (ignored when TitleContent is set). |
| TitleContent | RenderFragment | — | — | Rich title content. |
| ChildContent | RenderFragment | — | — | Body revealed when open. |
| Icon | DaisyCollapseIcon | Chevron | — | Chevron ( collapse-arrow ) or plus ( collapse-plus ) indicator. ChevronPlusNone |
| RadioGroupName | string | — | — | Renders a radio input sharing this name instead of a checkbox — daisyUI's accordion pattern: same-named radios are mutually exclusive natively, zero JS. |
| Class | string | — | — | Additional CSS classes appended to the component's computed daisyUI classes. |
| Style | string | — | — | Inline styles applied to the root element. |
Parameters
| Name | Type | Default | Binding | Description |
|---|---|---|---|---|
| ActiveKey | string | — | @bind-ActiveKey | Key of the currently open item ( null = none). Use with @bind-ActiveKey . |
| ChildContent | RenderFragment | — | — | The DAccordionItem entries. |
| Class | string | — | — | Additional CSS classes appended to the component's computed daisyUI classes. |
| Style | string | — | — | Inline styles applied to the root element. |
Parameters
| Name | Type | Default | Binding | Description |
|---|---|---|---|---|
| Key | string | — | — | Identity reported through the accordion's @bind-ActiveKey . |
| Title | string | — | — | Plain-text title (ignored when TitleContent is set). |
| TitleContent | RenderFragment | — | — | Rich title content. |
| ChildContent | RenderFragment | — | — | Body revealed when this item is the active one. |
| Icon | DaisyCollapseIcon | Chevron | — | Indicator icon for this item's collapse. ChevronPlusNone |
| Class | string | — | — | Additional CSS classes appended to the component's computed daisyUI classes. |
| Style | string | — | — | Inline styles applied to the root element. |