Let's start with an example problem: Visually replace the <input type="checkbox">
element with images. In this case, three states have been defined for the element:
.option {
margin: 10px;
float: left;
}
.option__input {
display: none;
}
.option__image {
padding: 3px;
border: 1px solid lightgray;
opacity: 0.5;
cursor: pointer;
transition: all .2s;
}
.option__image:hover {
border-color: blue;
opacity: 0.8;
}
.option__input:checked + .option__image {
border-color: green;
opacity: 1.0;
}
<p>Selecione as imagens desejadas:</p>
<div class="option">
<label>
<input type="checkbox" name="field[]" value="1" class="option__input">
<img src="https://via.placeholder.com/150"class="option__image">
</label>
</div>
<div class="option">
<label>
<input type="checkbox" name="field[]" value="1" class="option__input">
<img src="https://via.placeholder.com/150"class="option__image">
</label>
</div>
<div class="option">
<label>
<input type="checkbox" name="field[]" value="1" class="option__input">
<img src="https://via.placeholder.com/150"class="option__image">
</label>
</div>
Given the implementation, it may be noted that:
- When hovering over an element in the natural state, the hover state prevails, leaving the element with opacity 0.8 and blue edges;
- When hovering over an element in the selected state, the selected state prevails, leaving the element with 1.0 opacity and green edges;
I noticed that the fact that the selected state prevails over the hover state ends up causing an odd feeling, especially when only one element is selected. As the hover state indicates that the element is ready to change state between natural and selected, not applying it to the selected element makes it look like it is inert. Once selected, there is no way to change. Considering UX concepts, making this impression on the user does not seem like a good idea.
However, if you reverse the priorities of the states, so that the hover state prevails with the selected state, you will lose information. Once the element in the hover state the user will not know whether the element is selected or not until you move the mouse out of the element. I also do not see it as a good idea to force the user to do this.
After these considerations, I wondered if different states of the element should not be represented distinctly, so instead of overlapping they could increase. For example, representing the selected state with green borders and opacity 1.0, as already done, but representing the hover state with the scale of the element:
.option {
margin: 10px;
float: left;
}
.option__input {
display: none;
}
.option__image {
padding: 3px;
border: 1px solid lightgray;
opacity: 0.5;
cursor: pointer;
transition: all .2s;
}
.option__image:hover {
transform: scale(1.1);
opacity: 0.8;
}
.option__input:checked + .option__image {
border-color: green;
opacity: 1.0;
}
<p>Selecione as imagens desejadas:</p>
<div class="option">
<label>
<input type="checkbox" name="field[]" value="1" class="option__input">
<img src="https://via.placeholder.com/150"class="option__image">
</label>
</div>
<div class="option">
<label>
<input type="checkbox" name="field[]" value="1" class="option__input">
<img src="https://via.placeholder.com/150"class="option__image">
</label>
</div>
<div class="option">
<label>
<input type="checkbox" name="field[]" value="1" class="option__input">
<img src="https://via.placeholder.com/150"class="option__image">
</label>
</div>
So, I ask if, considering the user experience (UX) precepts, we must always represent different states of an element with different properties, in order to minimize or eliminate situations of information loss?