2021년 7월 7일 수요일

How to Design Better Checkbox, Radio and Toggle Buttons?

 Selection controls allow users to complete tasks which involve making choices such as selecting options, switching settings on or off, or adding or removing items.

Sizes

Radio buttons

Checkboxes

Toggle Buttons

Mind the tap area

Colors and different states

Conclusion

rontend Coding Tips

1. Hiding an HTML element


<p hidden>This paragraph won't show up. It's hidden by HTML.</p>

2. Use the inset shorthand in CSS


div{
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;

}
div{
position: absolute;
inset: 0;
}

 

3. Detect internet speed


navigator.connection.downlink;


4. Vibrate your phone


//vibrating the device for 500 millisecondswindow.navigator.vibrate(500);

5. Disable pull to refresh


body{
overscroll-behavior-y: contain;
}


6. Prevent the user from pasting text

<input type="text"></input><script>//selecting the input.
const input = document.querySelector('input');

//prevent the user to paste text by using the paste eventListener.
input.addEventListener("paste", function(e){
e.preventDefault()
})


</script>