Blazor.HeadlessUI.Dropdown 1.0.0

dotnet add package Blazor.HeadlessUI.Dropdown --version 1.0.0                
NuGet\Install-Package Blazor.HeadlessUI.Dropdown -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Blazor.HeadlessUI.Dropdown" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Blazor.HeadlessUI.Dropdown --version 1.0.0                
#r "nuget: Blazor.HeadlessUI.Dropdown, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Blazor.HeadlessUI.Dropdown as a Cake Addin
#addin nuget:?package=Blazor.HeadlessUI.Dropdown&version=1.0.0

// Install Blazor.HeadlessUI.Dropdown as a Cake Tool
#tool nuget:?package=Blazor.HeadlessUI.Dropdown&version=1.0.0                

Blazor Headless UI Dropdown

Examples

<DropdownWrapper @bind-IsOpen="_isOpen"
                 CssClassContainer="dropdown--content--container"
                 CssClassWrapper="dropdown--content__wrapper">
    <TriggerTemplate>
        <button @onclick="TriggerClickHandler" id="@context" class="btn--dropdown">
            @if (_selectedItem is not null)
            {
                <text>@_selectedItem</text>
            }
            else
            {
                <span>Select item</span>
            }
        </button>
    </TriggerTemplate>
    <ContentTemplate>
        <div class="items__wrapper">
            @foreach (var index in Enumerable.Range(0, 10))
            {
                <div class="item" @onclick="() => ItemClickHandler(index)">
                    Item @index
                </div>
            }
        </div>
    </ContentTemplate>
</DropdownWrapper>

@code {

    private int? _selectedItem;
    private bool _isOpen;

    private void TriggerClickHandler()
    {
        _isOpen = true;
        StateHasChanged();
    }

    private void ItemClickHandler(int index)
    {
        _selectedItem = index;
        _isOpen = false;
        StateHasChanged();
    }

}

app.css

.dropdown--content--container {
    position: absolute;
    left: -9999px;
    top: -9999px;
    box-sizing: border-box;
    overflow: auto;
    box-shadow: 0 0 16px rgba(0, 0, 0, 0.4);
}

/*...more styles*/

Preview

record

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 72 1/22/2025