Blazor playground

Nova v3.37.0

Preview

Blazor

Fieldmultiselect

← nv-fieldmultiselect

NvFieldmultiselect Component - Practical Guide for Blazor Developers

The NvFieldmultiselect component is a Blazor wrapper around Nova's multi-select dropdown component, providing advanced multiple selection capabilities with filtering, search, and bulk selection features. It supports both programmatic options and custom content slots.

General Blazor Concepts

For general information about data binding, forms, and validation in Nova Blazor components, see the Nova Blazor Integration Guide. This guide focuses on multi-select-specific features and patterns.

Basic Usage

Simple Multi-Select

razor<NvFieldmultiselect Label="Skills" Options="skillOptions" />

Multi-Select with Pre-selected Values

razor@code {
    private string[] selectedSkills = new[] { "javascript", "csharp" };
}

<NvFieldmultiselect
    @bind-Value="selectedSkills"
    Label="Select Your Skills"
    Options="skillOptions" />

Two-Way Data Binding

The component supports Blazor's @bind-Value syntax for seamless two-way data binding with string arrays:

Basic Binding

razor@code {
    private string[] selectedFruits = new string[] { };

    private NvFieldmultiselectOptions[] fruitOptions = new[]
    {
        new NvFieldmultiselectOptions { Label = "Apple", Value = "apple" },
        new NvFieldmultiselectOptions { Label = "Banana", Value = "banana" },
        new NvFieldmultiselectOptions { Label = "Orange", Value = "orange" },
        new NvFieldmultiselectOptions { Label = "Grape", Value = "grape" },
        new NvFieldmultiselectOptions { Label = "Strawberry", Value = "strawberry" }
    };
}

<NvFieldmultiselect
    @bind-Value="selectedFruits"
    Label="Favorite Fruits"
    Options="fruitOptions"
    Placeholder="Choose your favorite fruits..." />

@if (selectedFruits.Any())
{
    <div class="selection-summary">
        <h4>Selected Fruits (@selectedFruits.Length)</h4>
        <ul>
            @foreach (var fruit in selectedFruits)
            {
                <li>@fruitOptions.FirstOrDefault(o => o.Value == fruit)?.Label</li>
            }
        </ul>
    </div>
}

Dynamic Options and Selection

razor@code {
    private string[] selectedCategories = new string[] { };

    private NvFieldmultiselectOptions[] GetCategoryOptions()
    {
        return new[]
        {
            new NvFieldmultiselectOptions { Label = "Technology", Value = "tech", Description = "Latest in tech" },
            new NvFieldmultiselectOptions { Label = "Business", Value = "business", Description = "Business news" },
            new NvFieldmultiselectOptions { Label = "Sports", Value = "sports", Description = "Sports updates" },
            new NvFieldmultiselectOptions { Label = "Entertainment", Value = "entertainment", Description = "Movies & music" },
            new NvFieldmultiselectOptions { Label = "Science", Value = "science", Description = "Scientific discoveries" },
            new NvFieldmultiselectOptions { Label = "Health", Value = "health", Description = "Health & wellness" }
        };
    }
}

<NvFieldmultiselect
    @bind-Value="selectedCategories"
    Label="Newsletter Categories"
    Options="GetCategoryOptions()"
    Filterable="true"
    EnableSelectAll="true"
    SelectAllLabel="Subscribe to all"
    DeselectAllLabel="Unsubscribe from all" />

@if (selectedCategories.Length > 0)
{
    <div class="subscription-info">
        <p>You will receive @selectedCategories.Length newsletter categories</p>
    </div>
}

Event Handling

Using ValueChanged Event

razor<NvFieldmultiselect
    @bind-Value="selectedTags"
    Label="Tags"
    Options="tagOptions"
    ValueChanged="OnTagsChanged"
    Filterable="true" />

@if (selectedTags.Any())
{
    <div class="tag-cloud">
        @foreach (var tag in selectedTags)
        {
            <span class="tag">@tagOptions.FirstOrDefault(o => o.Value == tag)?.Label</span>
        }
    </div>
}

@code {
    private string[] selectedTags = new string[] { };
    private NvFieldmultiselectOptions[] tagOptions = new[]
    {
        new NvFieldmultiselectOptions { Label = "JavaScript", Value = "js" },
        new NvFieldmultiselectOptions { Label = "C#", Value = "csharp" },
        new NvFieldmultiselectOptions { Label = "Python", Value = "python" },
        new NvFieldmultiselectOptions { Label = "React", Value = "react" },
        new NvFieldmultiselectOptions { Label = "Angular", Value = "angular" },
        new NvFieldmultiselectOptions { Label = "Vue", Value = "vue" }
    };

    private void OnTagsChanged(string[] selectedValues)
    {
        selectedTags = selectedValues;
        // Could trigger API calls, update UI, etc.
        Console.WriteLine($"Selected {selectedValues.Length} tags");
    }
}

Filter Text Events

razor<NvFieldmultiselect
    @bind-Value="selectedCountries"
    Label="Countries"
    Options="countryOptions"
    Filterable="true"
    FilterTextChangedEvent="OnFilterChanged"
    DebounceDelay="200" />

@if (!string.IsNullOrEmpty(currentFilter))
{
    <div class="filter-info">
        <small>Filtering by: "@currentFilter"</small>
    </div>
}

@code {
    private string[] selectedCountries = new string[] { };
    private string currentFilter = "";

    private void OnFilterChanged(string filterText)
    {
        currentFilter = filterText ?? "";
        // Could log analytics, perform additional filtering logic, etc.
    }
}

Filtering and Search

Filterable Multi-Select

razor<NvFieldmultiselect
    @bind-Value="selectedEmployees"
    Label="Team Members"
    Options="employeeOptions"
    Filterable="true"
    Placeholder="Search for team members..."
    EmptyResult="No team members found" />

@code {
    private string[] selectedEmployees = new string[] { };

    private NvFieldmultiselectOptions[] employeeOptions = new[]
    {
        new NvFieldmultiselectOptions { Label = "John Doe", Value = "john", Description = "Senior Developer" },
        new NvFieldmultiselectOptions { Label = "Jane Smith", Value = "jane", Description = "Product Manager" },
        new NvFieldmultiselectOptions { Label = "Bob Johnson", Value = "bob", Description = "Designer" },
        new NvFieldmultiselectOptions { Label = "Alice Brown", Value = "alice", Description = "QA Engineer" },
        new NvFieldmultiselectOptions { Label = "Charlie Wilson", Value = "charlie", Description = "DevOps Engineer" }
    };
}

Custom Debounce Delay

razor<NvFieldmultiselect
    @bind-Value="selectedProducts"
    Label="Products"
    Options="productOptions"
    Filterable="true"
    DebounceDelay="500"
    Placeholder="Search products..." />

@code {
    private string[] selectedProducts = new string[] { };

    private NvFieldmultiselectOptions[] productOptions = new[]
    {
        new NvFieldmultiselectOptions { Label = "Laptop", Value = "laptop", Description = "High-performance laptop" },
        new NvFieldmultiselectOptions { Label = "Mouse", Value = "mouse", Description = "Wireless mouse" },
        new NvFieldmultiselectOptions { Label = "Keyboard", Value = "keyboard", Description = "Mechanical keyboard" },
        new NvFieldmultiselectOptions { Label = "Monitor", Value = "monitor", Description = "4K monitor" },
        new NvFieldmultiselectOptions { Label = "Headphones", Value = "headphones", Description = "Noise-cancelling headphones" }
    };
}

Select All Functionality

Enable Select All

razor<NvFieldmultiselect
    @bind-Value="selectedPermissions"
    Label="User Permissions"
    Options="permissionOptions"
    EnableSelectAll="true"
    SelectAllLabel="Grant all permissions"
    DeselectAllLabel="Revoke all permissions"
    BadgeLabel="permissions selected" />

@code {
    private string[] selectedPermissions = new string[] { };

    private NvFieldmultiselectOptions[] permissionOptions = new[]
    {
        new NvFieldmultiselectOptions { Label = "Read", Value = "read", Description = "View content" },
        new NvFieldmultiselectOptions { Label = "Write", Value = "write", Description = "Create and edit content" },
        new NvFieldmultiselectOptions { Label = "Delete", Value = "delete", Description = "Remove content" },
        new NvFieldmultiselectOptions { Label = "Admin", Value = "admin", Description = "Administrative access" },
        new NvFieldmultiselectOptions { Label = "Export", Value = "export", Description = "Export data" }
    };
}

Form Integration

The component integrates seamlessly with Blazor's EditForm for validation and form submission:

Basic Form Integration

razor<EditForm Model="projectModel" OnValidSubmit="CreateProject">
    <DataAnnotationsValidator />

    <NvFieldtext
        @bind-Value="projectModel.Name"
        Label="Project Name"
        For="() => projectModel.Name" />

    <NvFieldmultiselect
        @bind-Value="projectModel.Technologies"
        Label="Technologies Used"
        Options="technologyOptions"
        Filterable="true"
        For="() => projectModel.Technologies" />

    <NvFieldmultiselect
        @bind-Value="projectModel.TeamMembers"
        Label="Team Members"
        Options="teamMemberOptions"
        Filterable="true"
        EnableSelectAll="true"
        For="() => projectModel.TeamMembers" />

    <button type="submit">Create Project</button>
</EditForm>

@code {
    private ProjectModel projectModel = new();

    private void CreateProject()
    {
        // Process project creation
        Console.WriteLine("Project created successfully!");
    }

    public class ProjectModel
    {
        [Required]
        public string? Name { get; set; }

        [Required(ErrorMessage = "Please select at least one technology")]
        [MinLength(1, ErrorMessage = "Please select at least one technology")]
        public string[]? Technologies { get; set; }

        [Required(ErrorMessage = "Please assign team members")]
        [MinLength(1, ErrorMessage = "Please assign at least one team member")]
        public string[]? TeamMembers { get; set; }
    }
}

Validation

Required Multi-Select Validation

razor<EditForm Model="userProfile" OnValidSubmit="UpdateProfile">
    <DataAnnotationsValidator />

    <NvFieldmultiselect
        @bind-Value="userProfile.Interests"
        Label="Interests"
        Options="interestOptions"
        Required="true"
        Filterable="true"
        For="() => userProfile.Interests" />

    <NvFieldmultiselect
        @bind-Value="userProfile.Skills"
        Label="Skills"
        Options="skillOptions"
        Filterable="true"
        For="() => userProfile.Skills" />

    <button type="submit">Update Profile</button>
</EditForm>

@code {
    private UserProfile userProfile = new();

    public class UserProfile
    {
        [Required(ErrorMessage = "Please select at least one interest")]
        [CustomMinSelection(1, ErrorMessage = "Please select at least one interest")]
        public string[]? Interests { get; set; }

        public string[]? Skills { get; set; }
    }

    public class CustomMinSelectionAttribute : ValidationAttribute
    {
        private readonly int _minCount;

        public CustomMinSelectionAttribute(int minCount)
        {
            _minCount = minCount;
        }

        protected override ValidationResult? IsValid(object? value, ValidationContext validationContext)
        {
            var array = value as string[];
            if (array == null || array.Length < _minCount)
            {
                return new ValidationResult(ErrorMessage ?? $"Please select at least {_minCount} item(s)");
            }
            return ValidationResult.Success;
        }
    }
}

Custom Validation with Business Rules

razor<EditForm Model="projectAssignment" OnValidSubmit="AssignProject">
    <DataAnnotationsValidator />

    <NvFieldmultiselect
        @bind-Value="projectAssignment.RequiredSkills"
        Label="Required Skills"
        Options="skillOptions"
        Filterable="true"
        For="() => projectAssignment.RequiredSkills" />

    <NvFieldmultiselect
        @bind-Value="projectAssignment.AssignedMembers"
        Label="Assigned Team Members"
        Options="teamMemberOptions"
        Filterable="true"
        ValueChanged="ValidateAssignment"
        For="() => projectAssignment.AssignedMembers" />

    <button type="submit">Assign Project</button>
</EditForm>

@code {
    private ProjectAssignment projectAssignment = new();

    public class ProjectAssignment
    {
        [Required]
        [CustomSkillAssignment]
        public string[]? RequiredSkills { get; set; }

        [Required]
        [CustomSkillAssignment]
        public string[]? AssignedMembers { get; set; }
    }

    public class CustomSkillAssignmentAttribute : ValidationAttribute
    {
        protected override ValidationResult? IsValid(object? value, ValidationContext validationContext)
        {
            var assignment = (ProjectAssignment)validationContext.ObjectInstance;

            if (assignment.RequiredSkills == null || assignment.AssignedMembers == null)
                return ValidationResult.Success;

            // Business rule: Each assigned member should have at least one required skill
            foreach (var memberId in assignment.AssignedMembers)
            {
                var memberSkills = GetMemberSkills(memberId);
                if (!assignment.RequiredSkills.Any(skill => memberSkills.Contains(skill)))
                {
                    return new ValidationResult("Each assigned member must have at least one required skill");
                }
            }

            return ValidationResult.Success;
        }

        private string[] GetMemberSkills(string memberId)
        {
            // Mock skill data - in real app, this would come from a service
            return memberId switch
            {
                "john" => new[] { "javascript", "react" },
                "jane" => new[] { "csharp", "dotnet" },
                "bob" => new[] { "typescript", "angular" },
                "alice" => new[] { "python", "django" },
                _ => Array.Empty<string>()
            };
        }
    }

    private void ValidateAssignment(string[] assignedMembers)
    {
        // Additional real-time validation could go here
    }
}

Advanced Scenarios

Dynamic Options Based on Selection

razor<NvFieldmultiselect
    @bind-Value="selectedRegions"
    Label="Regions"
    Options="regionOptions"
    ValueChanged="OnRegionsChanged" />

@if (filteredCities.Any())
{
    <NvFieldmultiselect
        @bind-Value="selectedCities"
        Label="Cities"
        Options="filteredCities"
        Filterable="true" />
}

@code {
    private string[] selectedRegions = new string[] { };
    private string[] selectedCities = new string[] { };

    private NvFieldmultiselectOptions[] regionOptions = new[]
    {
        new NvFieldmultiselectOptions { Label = "North America", Value = "na" },
        new NvFieldmultiselectOptions { Label = "Europe", Value = "eu" },
        new NvFieldmultiselectOptions { Label = "Asia", Value = "asia" }
    };

    private NvFieldmultiselectOptions[] filteredCities = Array.Empty<NvFieldmultiselectOptions>();

    private void OnRegionsChanged(string[] regions)
    {
        selectedRegions = regions;
        selectedCities = Array.Empty<string>(); // Reset city selection

        if (regions.Contains("na"))
        {
            filteredCities = new[]
            {
                new NvFieldmultiselectOptions { Label = "New York", Value = "nyc" },
                new NvFieldmultiselectOptions { Label = "Los Angeles", Value = "la" },
                new NvFieldmultiselectOptions { Label = "Toronto", Value = "toronto" }
            };
        }
        else if (regions.Contains("eu"))
        {
            filteredCities = new[]
            {
                new NvFieldmultiselectOptions { Label = "London", Value = "london" },
                new NvFieldmultiselectOptions { Label = "Paris", Value = "paris" },
                new NvFieldmultiselectOptions { Label = "Berlin", Value = "berlin" }
            };
        }
        else if (regions.Contains("asia"))
        {
            filteredCities = new[]
            {
                new NvFieldmultiselectOptions { Label = "Tokyo", Value = "tokyo" },
                new NvFieldmultiselectOptions { Label = "Singapore", Value = "singapore" },
                new NvFieldmultiselectOptions { Label = "Hong Kong", Value = "hongkong" }
            };
        }
        else
        {
            filteredCities = Array.Empty<NvFieldmultiselectOptions>();
        }
    }
}

Bulk Operations with Programmatic Methods

razor<NvFieldmultiselect
    @bind-Value="selectedItems"
    @ref="multiSelectRef"
    Label="Items"
    Options="itemOptions"
    EnableSelectAll="true"
    Filterable="true" />

<div class="bulk-actions">
    <button @onclick="SelectAllFruits">Select All Fruits</button>
    <button @onclick="SelectAllVegetables">Select All Vegetables</button>
    <button @onclick="ClearSelection">Clear All</button>
    <button @onclick="ShowSelectedCount">Show Count</button>
</div>

@if (selectedItems.Any())
{
    <div class="selection-info">
        <p>@selectedItems.Length items selected</p>
        <ul>
            @foreach (var item in selectedItems)
            {
                <li>@itemOptions.FirstOrDefault(o => o.Value == item)?.Label</li>
            }
        </ul>
    </div>
}

@code {
    private string[] selectedItems = new string[] { };
    private NvFieldmultiselect? multiSelectRef;

    private NvFieldmultiselectOptions[] itemOptions = new[]
    {
        new NvFieldmultiselectOptions { Label = "Apple", Value = "apple", Description = "Fruit" },
        new NvFieldmultiselectOptions { Label = "Banana", Value = "banana", Description = "Fruit" },
        new NvFieldmultiselectOptions { Label = "Orange", Value = "orange", Description = "Fruit" },
        new NvFieldmultiselectOptions { Label = "Carrot", Value = "carrot", Description = "Vegetable" },
        new NvFieldmultiselectOptions { Label = "Broccoli", Value = "broccoli", Description = "Vegetable" },
        new NvFieldmultiselectOptions { Label = "Spinach", Value = "spinach", Description = "Vegetable" }
    };

    private async Task SelectAllFruits()
    {
        if (multiSelectRef != null)
        {
            await multiSelectRef.DeselectAllAsync();
            selectedItems = itemOptions
                .Where(o => o.Description == "Fruit")
                .Select(o => o.Value)
                .ToArray();
        }
    }

    private async Task SelectAllVegetables()
    {
        if (multiSelectRef != null)
        {
            await multiSelectRef.DeselectAllAsync();
            selectedItems = itemOptions
                .Where(o => o.Description == "Vegetable")
                .Select(o => o.Value)
                .ToArray();
        }
    }

    private async Task ClearSelection()
    {
        if (multiSelectRef != null)
        {
            await multiSelectRef.DeselectAllAsync();
        }
        selectedItems = Array.Empty<string>();
    }

    private async Task ShowSelectedCount()
    {
        if (multiSelectRef != null)
        {
            var values = await multiSelectRef.GetSelectedValuesAsync();
            Console.WriteLine($"Selected {values.Length} items");
        }
    }
}

Options with Dividers and Descriptions

razor<NvFieldmultiselect
    @bind-Value="selectedServices"
    Label="Select Services"
    Options="serviceOptions"
    Filterable="true"
    EnableSelectAll="true" />

@code {
    private string[] selectedServices = new string[] { };

    private NvFieldmultiselectOptions[] serviceOptions = new[]
    {
        new NvFieldmultiselectOptions { Label = "Basic Services", Value = "basic", IsDivider = true },
        new NvFieldmultiselectOptions { Label = "Web Hosting", Value = "hosting", Description = "Basic web hosting plan" },
        new NvFieldmultiselectOptions { Label = "Domain Registration", Value = "domain", Description = "Domain name registration" },
        new NvFieldmultiselectOptions { Label = "SSL Certificate", Value = "ssl", Description = "Security certificate" },

        new NvFieldmultiselectOptions { Label = "Advanced Services", Value = "advanced", IsDivider = true },
        new NvFieldmultiselectOptions { Label = "SEO Optimization", Value = "seo", Description = "Search engine optimization" },
        new NvFieldmultiselectOptions { Label = "Analytics Setup", Value = "analytics", Description = "Website analytics configuration" },
        new NvFieldmultiselectOptions { Label = "Backup Service", Value = "backup", Description = "Automated backup solution" },

        new NvFieldmultiselectOptions { Label = "Premium Services", Value = "premium", IsDivider = true },
        new NvFieldmultiselectOptions { Label = "Custom Development", Value = "custom-dev", Description = "Tailored development services" },
        new NvFieldmultiselectOptions { Label = "24/7 Support", Value = "support", Description = "Round-the-clock technical support" }
    };
}

Survey with Multi-Select Questions

razor<EditForm Model="surveyResponse" OnValidSubmit="SubmitSurvey">
    <DataAnnotationsValidator />

    <div class="survey-question">
        <NvFieldmultiselect
            @bind-Value="surveyResponse.CommunicationPrefs"
            Label="How do you prefer to receive communications?"
            Options="communicationOptions"
            EnableSelectAll="true"
            For="() => surveyResponse.CommunicationPrefs" />
    </div>

    <div class="survey-question">
        <NvFieldmultiselect
            @bind-Value="surveyResponse.Interests"
            Label="What topics are you interested in?"
            Options="interestOptions"
            Filterable="true"
            For="() => surveyResponse.Interests" />
    </div>

    <div class="survey-question">
        <NvFieldmultiselect
            @bind-Value="surveyResponse.Skills"
            Label="What skills do you have?"
            Options="skillOptions"
            Filterable="true"
            For="() => surveyResponse.Skills" />
    </div>

    <button type="submit">Submit Survey</button>
</EditForm>

@code {
    private SurveyResponse surveyResponse = new();

    public class SurveyResponse
    {
        [Required]
        public string[]? CommunicationPrefs { get; set; }

        [Required]
        public string[]? Interests { get; set; }

        public string[]? Skills { get; set; }
    }
}

Best Practices

  1. Use filtering for lists with more than 10 options to improve usability
  2. Enable select all/deselect all for convenience when appropriate
  3. Provide clear descriptions for complex options
  4. Use dividers to group related options logically
  5. Set appropriate debounce delays based on data size
  6. Handle large datasets with pagination or virtual scrolling if needed
  7. Validate selections based on business requirements
  8. Provide feedback on selection count and implications
  9. Consider keyboard navigation and accessibility
  10. Test with real data to ensure performance with large option lists

Common Patterns

User Role Assignment

razor<EditForm Model="userManagement" OnValidSubmit="UpdateUser">
    <DataAnnotationsValidator />

    <NvFieldtext
        @bind-Value="userManagement.Username"
        Label="Username"
        For="() => userManagement.Username" />

    <NvFieldmultiselect
        @bind-Value="userManagement.Roles"
        Label="User Roles"
        Options="roleOptions"
        EnableSelectAll="true"
        BadgeLabel="roles assigned"
        For="() => userManagement.Roles" />

    <NvFieldmultiselect
        @bind-Value="userManagement.Permissions"
        Label="Additional Permissions"
        Options="permissionOptions"
        Filterable="true"
        For="() => userManagement.Permissions" />

    <button type="submit">Update User</button>
</EditForm>

@code {
    private UserManagement userManagement = new();

    public class UserManagement
    {
        [Required]
        public string? Username { get; set; }

        [Required]
        public string[]? Roles { get; set; }

        public string[]? Permissions { get; set; }
    }

    private NvFieldmultiselectOptions[] roleOptions = new[]
    {
        new NvFieldmultiselectOptions { Label = "Administrator", Value = "admin", Description = "Full system access" },
        new NvFieldmultiselectOptions { Label = "Manager", Value = "manager", Description = "Team management access" },
        new NvFieldmultiselectOptions { Label = "User", Value = "user", Description = "Standard user access" },
        new NvFieldmultiselectOptions { Label = "Guest", Value = "guest", Description = "Limited access" }
    };

    private NvFieldmultiselectOptions[] permissionOptions = new[]
    {
        new NvFieldmultiselectOptions { Label = "Read Reports", Value = "read_reports" },
        new NvFieldmultiselectOptions { Label = "Edit Content", Value = "edit_content" },
        new NvFieldmultiselectOptions { Label = "Delete Items", Value = "delete_items" },
        new NvFieldmultiselectOptions { Label = "Export Data", Value = "export_data" },
        new NvFieldmultiselectOptions { Label = "Manage Users", Value = "manage_users" }
    };
}

Product Feature Selection

razor<EditForm Model="productConfig" OnValidSubmit="ConfigureProduct">
    <DataAnnotationsValidator />

    <NvFieldtext
        @bind-Value="productConfig.ProductName"
        Label="Product Name"
        For="() => productConfig.ProductName" />

    <NvFieldmultiselect
        @bind-Value="productConfig.IncludedFeatures"
        Label="Included Features"
        Options="featureOptions"
        EnableSelectAll="true"
        Filterable="true"
        For="() => productConfig.IncludedFeatures" />

    <NvFieldmultiselect
        @bind-Value="productConfig.OptionalAddons"
        Label="Optional Add-ons"
        Options="addonOptions"
        Filterable="true"
        For="() => productConfig.OptionalAddons" />

    <div class="pricing-summary">
        <h4>Total Price</h4>
        <p>Base Price: $@basePrice</p>
        <p>Add-ons: $@CalculateAddonsPrice()</p>
        <p><strong>Total: $@(basePrice + CalculateAddonsPrice())</strong></p>
    </div>

    <button type="submit">Configure Product</button>
</EditForm>

@code {
    private ProductConfig productConfig = new();
    private decimal basePrice = 99.99m;

    public class ProductConfig
    {
        [Required]
        public string? ProductName { get; set; }

        [Required]
        public string[]? IncludedFeatures { get; set; }

        public string[]? OptionalAddons { get; set; }
    }

    private NvFieldmultiselectOptions[] featureOptions = new[]
    {
        new NvFieldmultiselectOptions { Label = "Basic Support", Value = "basic_support", Description = "Email support" },
        new NvFieldmultiselectOptions { Label = "Advanced Analytics", Value = "analytics", Description = "Usage analytics" },
        new NvFieldmultiselectOptions { Label = "API Access", Value = "api_access", Description = "REST API integration" },
        new NvFieldmultiselectOptions { Label = "White Labeling", Value = "white_label", Description = "Custom branding" }
    };

    private NvFieldmultiselectOptions[] addonOptions = new[]
    {
        new NvFieldmultiselectOptions { Label = "Premium Support", Value = "premium_support", Description = "+$49.99/month" },
        new NvFieldmultiselectOptions { Label = "Advanced Security", Value = "security", Description = "+$29.99/month" },
        new NvFieldmultiselectOptions { Label = "Custom Integrations", Value = "integrations", Description = "+$99.99/month" },
        new NvFieldmultiselectOptions { Label = "Training Sessions", Value = "training", Description = "+$199.99/month" }
    };

    private decimal CalculateAddonsPrice()
    {
        if (productConfig.OptionalAddons == null) return 0;

        decimal total = 0;
        foreach (var addon in productConfig.OptionalAddons)
        {
            total += addon switch
            {
                "premium_support" => 49.99m,
                "security" => 29.99m,
                "integrations" => 99.99m,
                "training" => 199.99m,
                _ => 0
            };
        }
        return total;
    }
}

This guide covers the most common use cases and patterns for the NvFieldmultiselect component in Blazor applications. For more advanced scenarios or specific requirements, refer to the component's API documentation or the Storybook examples.