# Select > A custom dropdown select component with full keyboard navigation and accessibility support. Supports strings, enums, and complex objects. The Select component is part of SummitUI, a Blazor component library focused on WCAG-compliant, fully customizable headless components. ## Features - Generic type support (string, enums, objects) - Full keyboard navigation with typeahead - Grouped items with labels - Flexible positioning with collision detection - EditForm integration with validation - Controlled and uncontrolled modes - WCAG compliant with proper ARIA attributes ## Installation ```bash dotnet add package SummitUI ``` ## Anatomy Import the components and structure them as follows: ```razor Option 1 ``` ## Sub-components - **SelectRoot:** Generic root container managing select state. - **SelectTrigger:** Button that opens the dropdown (combobox role). - **SelectValue:** Displays selected value or placeholder text. - **SelectPortal:** Renders content in fixed-position container. - **SelectContent:** Floating listbox panel with positioning. - **SelectViewport:** Scrollable container for items. - **SelectItem:** Selectable option with option role. - **SelectItemText:** Text content wrapper for items. - **SelectGroup:** Groups related items together. - **SelectGroupLabel:** Label for a group of items. ## API Reference ### SelectRoot | Property | Type | Default | Description | |----------|------|---------|-------------| | Value | TValue? | null | Controlled selected value | | DefaultValue | TValue? | null | Default value (uncontrolled) | | ValueChanged | EventCallback | - | Value change callback | | Open | bool? | null | Controlled open state | | DefaultOpen | bool | false | Default open state | | OpenChanged | EventCallback | - | Open state change callback | | Disabled | bool | false | Disable entire select | | Required | bool | false | For form validation | | Invalid | bool | false | For error styling | ### SelectTrigger | Property | Type | Default | Description | |----------|------|---------|-------------| | As | string | "button" | HTML element to render | | AriaLabel | string? | null | Direct aria-label | ### SelectItem | Property | Type | Default | Description | |----------|------|---------|-------------| | Value | TValue | **required** | Value of this item | | Label | string? | null | Label for typeahead and display | | Disabled | bool | false | Disable item | ## Examples ### Basic Usage ```razor @code { private string? selectedFruit; } Apple Banana ``` ### Grouped Items ```razor Fruits Apple Vegetables Carrot ``` ## Styling ### Data Attributes | Attribute | Values | Description | |-----------|--------|-------------| | data-state | "open" \| "closed" | Dropdown open state | | data-state | "checked" \| "unchecked" | Item selection state | | data-highlighted | Present when focused | Item is keyboard-focused | | data-disabled | Present when disabled | Item or trigger is disabled | ## Accessibility ### Keyboard Navigation | Key | Action | |-----|--------| | Enter / Space | Open dropdown or select highlighted item | | ArrowDown | Open dropdown or move to next item | | ArrowUp | Move to previous item | | Escape | Close dropdown | | A-Z / a-z | Typeahead - jump to matching item |