mirror of
https://github.com/tabler/tabler.git
synced 2026-10-12 13:17:00 +04:00
163 lines
6.3 KiB
Plaintext
163 lines
6.3 KiB
Plaintext
---
|
|
title: Image check
|
|
order: 6
|
|
summary: Checkboxes and radios that use an image as the label, for picking a template, a theme or a product.
|
|
description: Checkboxes and radios with an image as the label, for choosing templates, themes or products in a form.
|
|
related: [/ui/forms/select-group, /ui/forms/color-check]
|
|
---
|
|
import Example from '@components/Example.astro';
|
|
|
|
## Default markup
|
|
|
|
An image check is a `.form-imagecheck` label with a hidden `.form-imagecheck-input`, a `.form-imagecheck-figure` that draws the check mark, and a `.form-imagecheck-image` for the picture.
|
|
|
|
```html
|
|
<label class="form-imagecheck">
|
|
<input name="..." type="checkbox" value="" class="form-imagecheck-input" checked />
|
|
<span class="form-imagecheck-figure">
|
|
<img src="..." alt="" class="form-imagecheck-image" />
|
|
</span>
|
|
</label>
|
|
```
|
|
|
|
<Example>
|
|
<div class="mb-3">
|
|
<label class="form-label">Image Check</label>
|
|
<div class="row g-2">
|
|
<div class="col-3">
|
|
<label class="form-imagecheck">
|
|
<input name="image" type="checkbox" value="1" class="form-imagecheck-input" />
|
|
<span class="form-imagecheck-figure">
|
|
<img src="/static/photos/everything-you-need-to-work-from-your-bed-2.jpg" alt="" class="form-imagecheck-image" />
|
|
</span>
|
|
</label>
|
|
</div>
|
|
<div class="col-3">
|
|
<label class="form-imagecheck">
|
|
<input name="image" type="checkbox" value="2" class="form-imagecheck-input" checked />
|
|
<span class="form-imagecheck-figure">
|
|
<img src="/static/photos/color-palette-guide-sample-colors-catalog-.jpg" alt="" class="form-imagecheck-image" />
|
|
</span>
|
|
</label>
|
|
</div>
|
|
<div class="col-3">
|
|
<label class="form-imagecheck">
|
|
<input name="image" type="checkbox" value="3" class="form-imagecheck-input" />
|
|
<span class="form-imagecheck-figure">
|
|
<img src="/static/photos/woman-read-book-and-drink-coffee-2.jpg" alt="" class="form-imagecheck-image" />
|
|
</span>
|
|
</label>
|
|
</div>
|
|
<div class="col-3">
|
|
<label class="form-imagecheck">
|
|
<input name="image" type="checkbox" value="4" class="form-imagecheck-input" checked />
|
|
<span class="form-imagecheck-figure">
|
|
<img src="/static/photos/stylish-workspace-with-macbook-pro-2.jpg" alt="" class="form-imagecheck-image" />
|
|
</span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</Example>
|
|
|
|
## Radio buttons
|
|
|
|
Change the input type to `radio` when only one option can be picked.
|
|
|
|
<Example>
|
|
<div class="mb-3">
|
|
<label class="form-label">Image Check Radio</label>
|
|
<div class="row g-2">
|
|
<div class="col-3">
|
|
<label class="form-imagecheck mb-2">
|
|
<input name="image" type="radio" value="1" class="form-imagecheck-input" />
|
|
<span class="form-imagecheck-figure">
|
|
<img src="/static/photos/woman-drinking-hot-tea-in-her-home-office.jpg" alt="" class="form-imagecheck-image" />
|
|
</span>
|
|
</label>
|
|
</div>
|
|
<div class="col-3">
|
|
<label class="form-imagecheck mb-2">
|
|
<input name="image" type="radio" value="2" class="form-imagecheck-input" checked />
|
|
<span class="form-imagecheck-figure">
|
|
<img src="/static/photos/young-woman-sitting-on-the-sofa-and-working-on-her-laptop-3.jpg" alt="" class="form-imagecheck-image" />
|
|
</span>
|
|
</label>
|
|
</div>
|
|
<div class="col-3">
|
|
<label class="form-imagecheck mb-2">
|
|
<input name="image" type="radio" value="3" class="form-imagecheck-input" />
|
|
<span class="form-imagecheck-figure">
|
|
<img src="/static/photos/beautiful-blonde-woman-relaxing-with-a-can-of-coke-on-a-tree-stump-by-the-beach.jpg" alt="" class="form-imagecheck-image" />
|
|
</span>
|
|
</label>
|
|
</div>
|
|
<div class="col-3">
|
|
<label class="form-imagecheck mb-2">
|
|
<input name="image" type="radio" value="4" class="form-imagecheck-input" checked />
|
|
<span class="form-imagecheck-figure">
|
|
<img src="/static/photos/book-on-the-grass.jpg" alt="" class="form-imagecheck-image" />
|
|
</span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</Example>
|
|
|
|
## Avatars
|
|
|
|
Use an [avatar](/ui/components/avatar) instead of an image when the options are people.
|
|
|
|
<Example>
|
|
<div class="mb-3">
|
|
<label class="form-label">Person Check</label>
|
|
<div class="row g-2">
|
|
<div class="col-auto">
|
|
<label class="form-imagecheck mb-2">
|
|
<input name="image" type="checkbox" value="1" class="form-imagecheck-input" />
|
|
<span class="form-imagecheck-figure">
|
|
<span class="form-imagecheck-image">
|
|
<span class="avatar avatar-xl" style="background-image: url(/static/avatars/057f.jpg)"></span>
|
|
</span>
|
|
</span>
|
|
</label>
|
|
</div>
|
|
<div class="col-auto">
|
|
<label class="form-imagecheck mb-2">
|
|
<input name="image" type="checkbox" value="2" class="form-imagecheck-input" checked />
|
|
<span class="form-imagecheck-figure">
|
|
<span class="form-imagecheck-image"><span class="avatar avatar-xl">HS</span></span>
|
|
</span>
|
|
</label>
|
|
</div>
|
|
<div class="col-auto">
|
|
<label class="form-imagecheck mb-2">
|
|
<input name="image" type="checkbox" value="3" class="form-imagecheck-input" />
|
|
<span class="form-imagecheck-figure">
|
|
<span class="form-imagecheck-image">
|
|
<span class="avatar avatar-xl" style="background-image: url(/static/avatars/062m.jpg)"></span>
|
|
</span>
|
|
</span>
|
|
</label>
|
|
</div>
|
|
<div class="col-auto">
|
|
<label class="form-imagecheck mb-2">
|
|
<input name="image" type="checkbox" value="4" class="form-imagecheck-input" checked />
|
|
<span class="form-imagecheck-figure">
|
|
<span class="form-imagecheck-image">
|
|
<span class="avatar avatar-xl" style="background-image: url(/static/avatars/070m.jpg)"></span>
|
|
</span>
|
|
</span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</Example>
|
|
|
|
## Accessibility
|
|
|
|
- An image check is a checkbox or a radio with a picture as its label. Keep the `input` in the markup so the control works and the state is exposed.
|
|
- A picture is not a name. Add text in the label, or an `aria-label` on the input, saying what the option is.
|
|
- Selection must not rest on the border color alone. Add a checkmark or another visible mark for the selected state.
|
|
- Wrap a set of them in a `fieldset` with a `legend`, so the group has a name.
|