XenForo Better Checkboxes

CR LEAKS

CR LEAKS

Administrative
Joined
Mar 25, 2022
Messages
1,272
Reaction score
5,191
Points
113
Credits
19,896
Overview

This simple CSS insert adds a nice subtle UI tweak for your checkboxes. First, we'll fade out unchecked boxes and labels to a softer color, helping to give them a "deactivated" appearance. Next, we highlight the checkbox color when hovering over an option.

When a box is checked, we'll change the label color back to normal giving it an "on" appearance. We'll apply fade transitions using the @xf-baseAnimationSpeed value, then optionally set the pointer cursor and checked icon weight (outline vs solid).

CSS snippet

Drop this into your extra.less template:
Code:
Please, Log in or Register to view codes content!
Editing the values

You only need the edit the following lines if needed, but the default values should work great on their own:

CSS:
Please, Log in or Register to view codes content!

The @controlColors set the color of checkbox icons (note that @controlColor--hover is also used for the checked state). The @controlLabelColors affect the label text when a box is checked or unchecked. Finally, you can make checked boxes solid by using 'bold', and change the cursor pointer.

A few notes

While this is somewhat expanded to make beginner-friendly edits, you could optimize this with CSS knowledge. Further, since this is being dropped into extra.less, the @control variables don't override those in core_input.less - so we need to duplicate some code from that template :whistle:. This could be avoided via an addon with Template Modifications. For the Less parent selector, we use the input[type="checkbox] in order to declare easy sibling combinators.
 
4,485Threads
10,412Messages
39,631Members
mika67Latest member
Top