Skip to content
Navigation Collapsible

Collapsible

A button that shows or hides a region, handled in the browser.

On this page

Examples

Collapsible

Closed content stays findable with find-in-page.

State: closed

Razor
<div class="flex w-full max-w-sm flex-col gap-4">
    <KlyCollapsible Label="Release notes" data-testid="plain">
        <p class="pt-2 text-sm text-(--klyroo-text-muted)" data-testid="plain-content">Everything new in this version, hidden until you ask.</p>
    </KlyCollapsible>

    <KlyCollapsible Label="Bound open state" @bind-Open="_open" data-testid="bound">
        <p class="pt-2 text-sm text-(--klyroo-text-muted)">.NET hears about every change.</p>
    </KlyCollapsible>
    <p class="text-sm text-(--klyroo-text-muted)" data-testid="open-state">State: @(_open ? "open" : "closed")</p>
</div>

@code {
    private bool _open;
}

API

KlyCollapsible

Disclosure made of a trigger and a region that opens and closes in the browser.

Parameters

Name Type Default Description
Class string Classes added to the root element, merged last so they win over the theme.
Disabled bool false Prevents the user from opening or closing the region.
Label string Text of the trigger button.
Open (@bind-Open) bool false Open state. Bind it with @bind-Open to hear about changes; unbound, nothing leaves the browser.
ShowIcon bool true Shows the chevron that turns when the region opens.
Ui CollapsibleUi Per-instance class overrides of the slots of the collapsible, see CollapsibleUi . They are merged after the theme and the Class parameter wins on the root slot.

Slots

Name Type Description
Trigger RenderFragment Custom content of the trigger button; replaces Label . It must not contain interactive elements.
ChildContent RenderFragment The revealed content.

Ui slots

Ui takes a CollapsibleUi with one class string per slot, merged after the theme.

Slot Styles
Root Classes merged into the root slot of KlyCollapsible , after the theme and the app configuration.
Trigger Classes merged into the trigger slot of KlyCollapsible , after the theme and the app configuration.
Label Classes merged into the label slot of KlyCollapsible , after the theme and the app configuration.
Icon Classes merged into the icon slot of KlyCollapsible , after the theme and the app configuration.
Content Classes merged into the content slot of KlyCollapsible , after the theme and the app configuration.