Components

Collapse

Collapsible sections allow to toggle content visibility, perfect for compact organization.

Usage

The collapse component is useful for organizing large amounts of information in a compact way.

  • src
    • app
    • pages
    • components
<ul class="min-w-48">
    <li>
        <div class="flex items-center gap-2 px-2 py-1 cursor-pointer rounded-lg hover:bg-indigo-50 hover:text-indigo-600"
             @onclick="@ToggleExpansion">
            <LumexIcon Icon="@FolderIcon" />
            <span>src</span>
        </div>
        <LumexCollapse As="ul"
                       Expanded="@_expanded"
                       Class="ml-4">
            @foreach( var dir in _directories )
            {
                <li class="flex items-center gap-2 px-2 py-1 cursor-pointer rounded-lg hover:bg-indigo-50 hover:text-indigo-600">
                    <LumexIcon Icon="@Icons.Rounded.Folder" />
                    <span>@dir</span>
                </li>
            }
        </LumexCollapse>
    </li>
</ul>

@code {
    private readonly string[] _directories = new string[]
    {
        "app", "pages", "components"
    };

    private bool _expanded = true;

    private string FolderIcon => _expanded
        ? Icons.Rounded.FolderOpen
        : Icons.Rounded.Folder;

    private void ToggleExpansion()
    {
        _expanded = !_expanded;
    }
}

Custom Styles

You can customize the collapse component by passing any Tailwind CSS classes to the component's Class parameter.


API

See the API references below for a complete guide to all the parameters available for the components mentioned here.

.

An unhandled error has occurred. Reload 🗙