Selectgroup
A set of radios or checkboxes styled as buttons (.form-selectgroup), for a filter bar or a set of options outside a
Symfony form. The real inputs stay in the markup, hidden with CSS: the arrow keys, the space bar and form submission
work as usual.
<twig:Tabler:Selectgroup name="language" items="{{ [ {value: 'html', label: 'HTML', checked: true}, {value: 'css', label: 'CSS'}, {value: 'php', label: 'PHP'}, {value: 'js', label: 'JavaScript'},] }}" role="group" aria-label="Language" /><div class="form-selectgroup" role="group" aria-label="Language"> <label class="form-selectgroup-item"> <input type="radio" name="language" value="html" class="form-selectgroup-input" checked /> <span class="form-selectgroup-label">HTML</span> </label> <label class="form-selectgroup-item"> <input type="radio" name="language" value="css" class="form-selectgroup-input" /> <span class="form-selectgroup-label">CSS</span> </label> <label class="form-selectgroup-item"> <input type="radio" name="language" value="php" class="form-selectgroup-input" /> <span class="form-selectgroup-label">PHP</span> </label> <label class="form-selectgroup-item"> <input type="radio" name="language" value="js" class="form-selectgroup-input" /> <span class="form-selectgroup-label">JavaScript</span> </label></div>Each entry of items is a Selectgroup:Item: a value, and an optional label, icon, iconOnly, checked and
disabled. Give the group an accessible name: role="group" and an aria-label, or a <fieldset> with a <legend>
around it.
Several choices
Section titled “Several choices”type="checkbox" lets the user pick several options; end the name with [] so the server gets them all:
<twig:Tabler:Selectgroup name="status[]" type="checkbox" items="{{ [ {value: 'open', label: 'Open', checked: true}, {value: 'review', label: 'In review', checked: true}, {value: 'closed', label: 'Closed'}, {value: 'archived', label: 'Archived', disabled: true},] }}" role="group" aria-label="Status" /><div class="form-selectgroup" role="group" aria-label="Status"> <label class="form-selectgroup-item"> <input type="checkbox" name="status[]" value="open" class="form-selectgroup-input" checked /> <span class="form-selectgroup-label">Open</span> </label> <label class="form-selectgroup-item"> <input type="checkbox" name="status[]" value="review" class="form-selectgroup-input" checked /> <span class="form-selectgroup-label">In review</span> </label> <label class="form-selectgroup-item"> <input type="checkbox" name="status[]" value="closed" class="form-selectgroup-input" /> <span class="form-selectgroup-label">Closed</span> </label> <label class="form-selectgroup-item"> <input type="checkbox" name="status[]" value="archived" class="form-selectgroup-input" disabled /> <span class="form-selectgroup-label">Archived</span> </label></div>icon puts an icon before the label. With iconOnly, only the icon shows, and the label becomes the aria-label of
the input:
<div class="d-flex flex-column gap-3"> <twig:Tabler:Selectgroup name="weather[]" type="checkbox" items="{{ [ {value: 'sun', label: 'Sunny', icon: 'sun', iconOnly: true, checked: true}, {value: 'moon', label: 'Clear night', icon: 'moon', iconOnly: true}, {value: 'rain', label: 'Rain', icon: 'cloud-rain', iconOnly: true}, {value: 'other', label: 'Other'}, ] }}" role="group" aria-label="Weather" /> <twig:Tabler:Selectgroup name="view" items="{{ [ {value: 'home', label: 'Home', icon: 'home', checked: true}, {value: 'user', label: 'User', icon: 'user'}, {value: 'settings', label: 'Settings', icon: 'settings'}, ] }}" role="group" aria-label="View" /></div><div class="d-flex flex-column gap-3"> <div class="form-selectgroup" role="group" aria-label="Weather"> <label class="form-selectgroup-item"> <input type="checkbox" name="weather[]" value="sun" class="form-selectgroup-input" checked aria-label="Sunny" /> <span class="form-selectgroup-label"><i class="ti ti-sun"></i></span> </label> <label class="form-selectgroup-item"> <input type="checkbox" name="weather[]" value="moon" class="form-selectgroup-input" aria-label="Clear night" /> <span class="form-selectgroup-label"><i class="ti ti-moon"></i></span> </label> <label class="form-selectgroup-item"> <input type="checkbox" name="weather[]" value="rain" class="form-selectgroup-input" aria-label="Rain" /> <span class="form-selectgroup-label"><i class="ti ti-cloud-rain"></i></span> </label> <label class="form-selectgroup-item"> <input type="checkbox" name="weather[]" value="other" class="form-selectgroup-input" /> <span class="form-selectgroup-label">Other</span> </label> </div> <div class="form-selectgroup" role="group" aria-label="View"> <label class="form-selectgroup-item"> <input type="radio" name="view" value="home" class="form-selectgroup-input" checked /> <span class="form-selectgroup-label"> <i class="ti ti-home me-1"></i> Home </span> </label> <label class="form-selectgroup-item"> <input type="radio" name="view" value="user" class="form-selectgroup-input" /> <span class="form-selectgroup-label"> <i class="ti ti-user me-1"></i> User </span> </label> <label class="form-selectgroup-item"> <input type="radio" name="view" value="settings" class="form-selectgroup-input" /> <span class="form-selectgroup-label"> <i class="ti ti-settings me-1"></i> Settings </span> </label> </div></div><twig:Tabler:Selectgroup name="tags[]" type="checkbox" variant="pills" items="{{ [ {value: 'bug', label: 'Bug', checked: true}, {value: 'feature', label: 'Feature'}, {value: 'docs', label: 'Documentation'}, {value: 'question', label: 'Question'},] }}" role="group" aria-label="Tags" /><div class="form-selectgroup form-selectgroup-pills" role="group" aria-label="Tags"> <label class="form-selectgroup-item"> <input type="checkbox" name="tags[]" value="bug" class="form-selectgroup-input" checked /> <span class="form-selectgroup-label">Bug</span> </label> <label class="form-selectgroup-item"> <input type="checkbox" name="tags[]" value="feature" class="form-selectgroup-input" /> <span class="form-selectgroup-label">Feature</span> </label> <label class="form-selectgroup-item"> <input type="checkbox" name="tags[]" value="docs" class="form-selectgroup-input" /> <span class="form-selectgroup-label">Documentation</span> </label> <label class="form-selectgroup-item"> <input type="checkbox" name="tags[]" value="question" class="form-selectgroup-input" /> <span class="form-selectgroup-label">Question</span> </label></div>variant="boxes" turns each option into a box with a check mark, round for radios and square for checkboxes.
vertical stacks the items in a column:
<twig:Tabler:Selectgroup name="plan" variant="boxes" vertical="{{ true }}" items="{{ [ {value: 'free', label: 'Free'}, {value: 'pro', label: 'Pro', checked: true}, {value: 'team', label: 'Team'},] }}" role="group" aria-label="Plan" /><div class="form-selectgroup form-selectgroup-boxes form-selectgroup-vertical" role="group" aria-label="Plan"> <label class="form-selectgroup-item"> <input type="radio" name="plan" value="free" class="form-selectgroup-input" /> <span class="form-selectgroup-label d-flex align-items-center p-3"> <span class="me-3"><span class="form-selectgroup-check"></span></span> <span>Free</span> </span> </label> <label class="form-selectgroup-item"> <input type="radio" name="plan" value="pro" class="form-selectgroup-input" checked /> <span class="form-selectgroup-label d-flex align-items-center p-3"> <span class="me-3"><span class="form-selectgroup-check"></span></span> <span>Pro</span> </span> </label> <label class="form-selectgroup-item"> <input type="radio" name="plan" value="team" class="form-selectgroup-input" /> <span class="form-selectgroup-label d-flex align-items-center p-3"> <span class="me-3"><span class="form-selectgroup-check"></span></span> <span>Team</span> </span> </label></div>Composed
Section titled “Composed”The tag content replaces the items: place Selectgroup:Item yourself, each with its name. The content of an item
replaces its icon and label; check adds the check mark of a box:
<twig:Tabler:Selectgroup variant="boxes" vertical="{{ true }}" role="group" aria-label="Billing"> <twig:Tabler:Selectgroup:Item name="billing" value="monthly" check="{{ true }}" class="flex-fill"> <strong>Monthly</strong> — $29 per month </twig:Tabler:Selectgroup:Item> <twig:Tabler:Selectgroup:Item name="billing" value="yearly" check="{{ true }}" checked="{{ true }}" class="flex-fill"> <strong>Yearly</strong> — $290 per year, two months free </twig:Tabler:Selectgroup:Item></twig:Tabler:Selectgroup><div class="form-selectgroup form-selectgroup-boxes form-selectgroup-vertical" role="group" aria-label="Billing"> <label class="form-selectgroup-item flex-fill"> <input type="radio" name="billing" value="monthly" class="form-selectgroup-input" /> <span class="form-selectgroup-label d-flex align-items-center p-3"> <span class="me-3"><span class="form-selectgroup-check"></span></span> <span> <strong>Monthly</strong> — $29 per month </span> </span> </label> <label class="form-selectgroup-item flex-fill"> <input type="radio" name="billing" value="yearly" class="form-selectgroup-input" checked /> <span class="form-selectgroup-label d-flex align-items-center p-3"> <span class="me-3"><span class="form-selectgroup-check"></span></span> <span> <strong>Yearly</strong> — $290 per year, two months free </span> </span> </label></div>| Prop | Type | Default | Description |
|---|---|---|---|
name |
string? | null |
The name of every input; end it with [] for checkboxes |
type |
string | 'radio' |
radio (one choice) or checkbox (several) |
items |
list | [] |
{value, label?, icon?, iconOnly?, checked?, disabled?} entries, one Selectgroup:Item each |
variant |
string? | null |
pills (form-selectgroup-pills) or boxes (form-selectgroup-boxes, with a check) |
vertical |
bool | false |
Stacks the items in a column (form-selectgroup-vertical) |
Other attributes go to the root <div class="form-selectgroup">.
Selectgroup:Item
Section titled “Selectgroup:Item”| Prop | Type | Default | Description |
|---|---|---|---|
type |
string | 'radio' |
radio or checkbox |
name |
string? | null |
The name of the input |
value |
string? | null |
The value of the input |
label |
string? | null |
The option text |
icon |
string? | null |
Tabler icon name (or ux-icons name) before the text |
iconOnly |
bool | false |
Shows only the icon; label becomes the input’s aria-label |
checked |
bool | false |
Initially selected |
disabled |
bool | false |
Cannot be selected |
check |
bool | false |
Adds a check mark before the content (Selectgroup:Check) |
Other attributes go to its root <label>.
Selectgroup:Label
Section titled “Selectgroup:Label”| Prop | Type | Default | Description |
|---|---|---|---|
check |
bool | false |
Puts a Selectgroup:Check before the content, laid out as a box |
Sub-components
Section titled “Sub-components”| Component | Renders |
|---|---|
Selectgroup:Item |
<label class="form-selectgroup-item">, with the hidden form-selectgroup-input |
Selectgroup:Label |
<span class="form-selectgroup-label">, the visible part of an item |
Selectgroup:Check |
<span class="form-selectgroup-check">, the check mark of a box |
Blocks
Section titled “Blocks”| Block | Default |
|---|---|
items |
A Selectgroup:Item per entry of items |
content |
items: replace it to compose freely |
Selectgroup:Item has an icon block (a Tabler:Icon named icon) and a content block (icon and the label),
which its tag content replaces.
