Table of Contents

Class TwCollapse

Namespace
TwBlazor.Components
Assembly
TwBlazor.dll

Represents a collapsible drawer component that shows or hides content when triggered.

public class TwCollapse : TwBlazorComponentBase, IComponent, IHandleEvent, IHandleAfterRender, ITwComponent
Inheritance
TwCollapse
Implements
Inherited Members

Remarks

The TwCollapse component provides an accessible, animated panel that expands and collapses when the trigger button is clicked. It supports two-way binding via IsOpen and IsOpenChanged, and can notify consumers of each toggle via OnToggle.

Constructors

TwCollapse()

public TwCollapse()

Properties

ChildContent

Gets or sets the content displayed inside the collapsible panel.

[Parameter]
public RenderFragment? ChildContent { get; set; }

Property Value

RenderFragment

HeaderContent

Gets or sets custom content to display inside the collapse trigger button.

[Parameter]
public RenderFragment? HeaderContent { get; set; }

Property Value

RenderFragment

Remarks

When provided, takes precedence over Title.

IsOpen

Gets or sets a value indicating whether the collapsible panel is open.

[Parameter]
public bool IsOpen { get; set; }

Property Value

bool

IsOpenChanged

Gets or sets the callback invoked when IsOpen changes.

[Parameter]
public EventCallback<bool> IsOpenChanged { get; set; }

Property Value

EventCallback<bool>

OnToggle

Gets or sets the callback invoked when the collapse is toggled, providing the new open state.

[Parameter]
public EventCallback<bool> OnToggle { get; set; }

Property Value

EventCallback<bool>

Title

Gets or sets the title text displayed in the collapse trigger button.

[Parameter]
public string? Title { get; set; }

Property Value

string

Remarks

Ignored when HeaderContent is provided.

Methods

BuildRenderTree(RenderTreeBuilder)

Renders the component to the supplied RenderTreeBuilder.

protected override void BuildRenderTree(RenderTreeBuilder __builder)

Parameters

__builder RenderTreeBuilder