Collapse & Accordion

DCollapse is driven by a hidden checkbox that daisy lays over the title row — toggling is pure CSS. Bind @bind-Open when Blazor needs to know (or steer) the state. DAccordion stacks items on one shared radio group, so exclusivity is native.

Basic collapse— Unbound — CSS handles it, no Blazor roundtrip
What is this?

A collapse collapse-arrow with checkbox, title and content — daisyUI does the rest.

Plus icon

collapse-plus swaps the chevron for a plus/minus indicator.

<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>
Bound open state— @bind-Open — Blazor mirrors (and can change) the state
Toggle me

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;
}
Accordion— Same-name radios — only one item open, zero JS
Shipping

Free shipping on orders over $50.

Returns

30-day no-questions returns.

Warranty

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 + @bind-Open when closing matters.

<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

DCollapse

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.
DAccordion

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.
DAccordionItem

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.
Connection lost — reconnecting…
Connection failed.
The server has stopped.