Learn how to work with checkboxes, radio buttons, select elements, and advanced collection patterns in Aurelia forms.
Overview
Aurelia provides sophisticated support for collection-based form controls, going beyond simple arrays to support Sets, Maps, and custom collection types with optimal performance.
Checkboxes
Boolean Checkboxes
The simplest checkbox pattern binds to boolean properties:
<form><fieldset><legend>Notification Preferences</legend><label><inputtype="checkbox"checked.bind="emailNotifications"/> Email notifications</label><label><inputtype="checkbox"checked.bind="smsNotifications"/> SMS notifications</label><label><inputtype="checkbox"checked.bind="pushNotifications"/> Push notifications</label></fieldset><divif.bind="!hasValidNotificationPrefs"class="warning"> Please select at least one notification method.</div></form>
Key Points:
Use checked.bind for boolean checkboxes
Works with any boolean property
Great for independent on/off toggles
Array-Based Multi-Select
For multi-select scenarios, bind arrays to checkbox groups using model.bind:
How It Works:
model.bind tells Aurelia what value to add to the array
checked.bind points to the array that holds selected values
Aurelia automatically adds/removes values when checkboxes are toggled
Use Cases:
Multi-select forms (select multiple skills, interests, tags)
Batch operations (select multiple items for deletion)
Filter selections (select multiple categories to filter by)
Set-Based Collections
For high-performance scenarios with frequent additions/removals, use Set collections:
Why Use Sets:
O(1) lookup performance with .has()
Efficient for large collections
Natural for unique value storage
Better performance for frequent add/remove operations
Map-Based Collections
For complex key-value selections, Maps provide the most flexibility:
When to Use Maps:
Nested selection scenarios (resource → actions)
Complex key-value relationships
Grouped permissions or settings
Multi-dimensional selections
Radio Buttons
Radio buttons are for single-selection from multiple options.
Basic Radio Buttons
Radio Buttons with Objects
Key Points:
Use same name attribute for all radios in a group
model.bind defines the value when selected
checked.bind holds the currently selected value
Use matcher.bind for complex object comparison
Select Elements
Basic Select
Select with Objects
Select with Optgroups
Multi-Select
Performance Considerations
Choose the right collection type for your use case:
Collection Type
Best For
Performance
Array
General purpose, small-medium collections
Good
Set
Frequent additions/removals, uniqueness
Excellent (O(1) lookups)
Map
Key-value pairs, nested selections
Excellent (O(1) lookups)
Performance Tips:
Use Set for large collections with frequent changes
Implement efficient matcher functions for object comparison
Avoid creating new objects in templates—use computed properties
Consider virtualization for very large checkbox/radio lists
Matchers Explained
By default, Aurelia compares values with strict equality (===). That works for primitives and for objects that are the exact same instance. It does not work when your selected value and your option values are different instances that represent the same logical entity (for example, data reloaded from an API). A matcher lets you define what "equal" means so selections stay in sync.