@inherits DComponentBase @* daisyUI Collapse: https://daisyui.com/components/collapse/ . The open state lives in C# (@bind-IsOpen) and is rendered with collapse-open / collapse-close; clicking the header (or Enter/Space on it) toggles it. neo-raised gives it the neumorphic panel look (see Styles/neo.css for why it isn't a @utility override). *@
@Header
@ChildContent
@code { [Parameter] public RenderFragment Header { get; set; } [Parameter] public RenderFragment ChildContent { get; set; } [Parameter] public bool IsOpen { get; set; } [Parameter] public EventCallback IsOpenChanged { get; set; } [Parameter] public DCollapseIcon Icon { get; set; } [Parameter] public bool Disabled { get; set; } [Parameter] public string HeaderClass { get; set; } [Parameter] public string ContentClass { get; set; } string CssClass => Cx("collapse neo-raised", IconClass, IsOpen ? "collapse-open" : "collapse-close", Class); string IconClass => Icon switch { DCollapseIcon.Arrow => "collapse-arrow", DCollapseIcon.Plus => "collapse-plus", _ => null }; async Task Toggle() { if (Disabled) return; IsOpen = !IsOpen; await IsOpenChanged.InvokeAsync(IsOpen); } Task OnKeyDown(KeyboardEventArgs e) => e.Key is "Enter" or " " ? Toggle() : Task.CompletedTask; }