| Class name | Type | Description |
|---|---|---|
filter |
Component | For a HTML <form> or a <div> element that includes radio buttons for filtering items |
filter-reset |
Part | An alternative to the reset button if you can't use a HTML form |
A HTML form for filtering items
<form class="filter">
<input class="btn btn-square" type="reset" value="×" />
<input class="btn" type="radio" name="frameworks" aria-label="Svelte" />
<input class="btn" type="radio" name="frameworks" aria-label="Vue" />
<input class="btn" type="radio" name="frameworks" aria-label="React" />
</form>
Filter(
[
input(classes: 'btn btn-square', type: InputType.reset, value: '×'),
input(
classes: 'btn',
type: InputType.radio,
name: 'frameworks',
attributes: {'aria-label': 'Svelte'},
),
input(
classes: 'btn',
type: InputType.radio,
name: 'frameworks',
attributes: {'aria-label': 'Vue'},
),
input(
classes: 'btn',
type: InputType.radio,
name: 'frameworks',
attributes: {'aria-label': 'React'},
),
],
);
Use this if you can't use a HTML form for some reason
<div class="filter">
<input class="btn filter-reset" type="radio" name="metaframeworks" aria-label="All" />
<input class="btn" type="radio" name="metaframeworks" aria-label="Sveltekit" />
<input class="btn" type="radio" name="metaframeworks" aria-label="Nuxt" />
<input class="btn" type="radio" name="metaframeworks" aria-label="Next.js" />
</div>
div(
[
FilterReset(
const [],
classes: 'btn',
type: 'radio',
name: 'metaframeworks',
attributes: {'aria-label': 'All'},
),
input(
classes: 'btn',
type: InputType.radio,
name: 'metaframeworks',
attributes: {'aria-label': 'Sveltekit'},
),
input(
classes: 'btn',
type: InputType.radio,
name: 'metaframeworks',
attributes: {'aria-label': 'Nuxt'},
),
input(
classes: 'btn',
type: InputType.radio,
name: 'metaframeworks',
attributes: {'aria-label': 'Next.js'},
),
],
classes: 'filter',
);
For having multiple choices, use checkboxes.
<form class="filter">
<input class="btn" type="checkbox" name="frameworks" aria-label="Svelte" />
<input class="btn" type="checkbox" name="frameworks" aria-label="Vue" />
<input class="btn" type="checkbox" name="frameworks" aria-label="React" />
<input class="btn btn-square" type="reset" value="×" />
</form>
Filter(
[
input(
classes: 'btn',
type: InputType.checkbox,
name: 'frameworks',
attributes: {'aria-label': 'Svelte'},
),
input(
classes: 'btn',
type: InputType.checkbox,
name: 'frameworks',
attributes: {'aria-label': 'Vue'},
),
input(
classes: 'btn',
type: InputType.checkbox,
name: 'frameworks',
attributes: {'aria-label': 'React'},
),
input(classes: 'btn btn-square', type: InputType.reset, value: '×'),
],
);