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
<PackageReference Include="kwolo.blazor.ImageDropdown" Version="1.0.3" />
<PackageVersion Include="kwolo.blazor.ImageDropdown" Version="1.0.3" />
<PackageReference Include="kwolo.blazor.ImageDropdown" />
paket add kwolo.blazor.ImageDropdown --version 1.0.3
#r "nuget: kwolo.blazor.ImageDropdown, 1.0.3"
#:package kwolo.blazor.ImageDropdown@1.0.3
#addin nuget:?package=kwolo.blazor.ImageDropdown&version=1.0.3
#tool nuget:?package=kwolo.blazor.ImageDropdown&version=1.0.3
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 ImageDropdownItem
s, 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 | Versions 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. |
-
net9.0
- Microsoft.AspNetCore.Components.Web (>= 9.0.6)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.