kwolo.blazor.ImageDropdown 1.0.3

dotnet add package kwolo.blazor.ImageDropdown --version 1.0.3
                    
NuGet\Install-Package kwolo.blazor.ImageDropdown -Version 1.0.3
                    
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="kwolo.blazor.ImageDropdown" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="kwolo.blazor.ImageDropdown" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="kwolo.blazor.ImageDropdown" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add kwolo.blazor.ImageDropdown --version 1.0.3
                    
#r "nuget: kwolo.blazor.ImageDropdown, 1.0.3"
                    
#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.
#:package kwolo.blazor.ImageDropdown@1.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=kwolo.blazor.ImageDropdown&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=kwolo.blazor.ImageDropdown&version=1.0.3
                    
Install as a Cake Tool

Blazor Image Dropdown

Overview

This blazor component is based on the awesome (and awesomely named!) Tom Select JS library and is primarily intended to address the bizarre shortfall in the HTML spec that is dropdowns-with-images.

Project and nuget URLS

The project repo is hosted on gitlab

The nuget package is available as kwolo.blazor.ImageDropdown

Installation

To get going in a blazor app, add the "kwolo.blazor.ImageDropdown" nuget package then update index.html to include the two javascript files:

    /* Insert these two lines */
    <script src="_content/kwolo.blazor.ImageDropdown/js/tomSelect.js"></script>
    <script src="_content/kwolo.blazor.ImageDropdown/js/tomSelectHandler.js"></script>

    /* Your existing webassembly call */
    <script src="_framework/blazor.webassembly.js"></script>

In your App.razor file, add a reference to ImageDropdownResources:

/* Add these two lines */
@using kwolo.blazor.ImageDropdown
<ImageDropdownResources />

/* The rest of your app.razor */
<Router AppAssembly="@typeof(App).Assembly">
    <Found...

Usage

To use the control, check out the demo project's Home.razor

You will construct a list of ImageDropdownItems, each of which consist of a Value (same as a <select> option value), a Name (the textual display for the option) and an optional ImageUrl. The Value properties can be of any type.

If ImageUrl is supplied that that is used to display the image within the dropdown.

To display the dropdown, include an ImageDropdown component in your blazor / razor file:

<div class="select-wrapper">
    <ImageDropdown Items="_items" @bind-Value="_selectedValue"></ImageDropdown>
</div>

And that's pretty much it. The only potential gotcha is that the dropdown will inherit the width of its parent container, hence the class="select-wrapper" specifier above. That allows us to set something like the following in the attendant CSS file:

.select-wrapper {
    width: 12rem;
}
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.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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.3 224 6/18/2025
1.0.2 147 6/14/2025
1.0.1 150 6/14/2025
1.0.0 149 6/14/2025