Overview
The createSingle composable extendscreateSelection to enforce single-selection behavior. It automatically clears previous selections when a new item is selected and provides singular computed properties instead of plural sets.
Perfect for tabs, radio buttons, theme selectors, and other single-choice UI components.
Signature
Configuration options (inherits from SelectionOptions)
Single-selection instance with singular properties
Usage
Basic Single Selection
Mandatory Selection
Force Mandatory
Singular Computed Properties
Toggle Behavior
Disabled Items
Enroll Option
Vue Component Example
Type Safety
Context Pattern
Comparison with createSelection
| Feature | createSelection | createSingle |
|---|---|---|
| Multiple selection | Yes (with multiple: true) | No (always single) |
| Computed properties | Plural (selectedItems, selectedValues) | Singular (selectedItem, selectedValue, selectedIndex) |
Default multiple | false | Always false |
| Auto-clear on select | Only when multiple: false | Always |
| Use case | Multi-select, checkboxes | Tabs, radio buttons, theme selector |
Performance
- Selection changes: O(1) for single item operations
selectedId: O(1) computed from Set iteratorselectedItem: O(1) computed from selectedIdselectedIndex: O(1) from ticket’s index propertyselectedValue: O(1) from ticket’s value property
See Also
- createSelection - Base selection system
- createStep - Single-selection with navigation
- createGroup - Multi-selection variant