Checkboxes are a common UI element that allow users to select one or more options from a set. By default, checkboxes are fairly small in size. However, in some cases, you may want to increase the checkbox size to make it more visible and easier for users to click.
In this comprehensive guide, we‘ll explore different methods to increase checkbox size in CSS.
Why Would You Want Bigger Checkboxes?
Here are some common reasons why you may want larger checkboxes on your web page or app:
-
Improve usability – Larger checkboxes are easier for users to see and click, especially on touch devices. This improves the overall usability.
-
Accessibility – Large controls can help users who have reduced motor control or visual impairments.
-
Draw attention – In some designs, you want important choices to stand out more. Increasing the checkbox size can help highlight key options.
-
Fit design needs – Your design layout may require checkboxes to be a certain minimum size.
So in summary, checkbox size impacts both aesthetics and usability. Don‘t assume one-size-fits-all – consider the context and needs of your users.
Method 1: Use width and height Properties
The easiest way to increase checkbox size is by setting the width and height properties in CSS:
input[type="checkbox"] {
width: 30px;
height: 30px;
}
This will make the checkbox 30px wide and tall.
For example:
<input type="checkbox"> Remember me
input[type="checkbox"] {
width: 30px;
height: 30px;
}
See the Pen
Untitled by retina (@retina99)
on CodePen.
The advantage of this method is it‘s simple and works consistently across browsers. The limitation is that it forces a fixed size which doesn‘t scale responsively.
Method 2: scale Transform
For responsive scaling, you can use CSS transform: scale(). This will resize the checkbox relative to its default size:
input[type="checkbox"] {
transform: scale(2);
}
The above code doubles the checkbox size (scale factor of 2). You can use any value – higher numbers make it bigger.
Here is an example:
<input type="checkbox"> Accept terms
input[type="checkbox"] {
transform: scale(1.5);
}
See the Pen
Untitled by retina (@retina99)
on CodePen.
The benefit of using transform is that it scales responsively, without needing media queries. The higher you set the value, the larger it gets.
One thing to note is that transform does not affect the position or layout, only the visual appearance. So surrounding elements won‘t be impacted.
Method 3: Use a Label Wrapper
This method involves wrapping the checkbox input inside a <label> element. You can then style the label as needed:
<label>
<input type="checkbox">
Remember choice
</label>
label {
display: flex;
align-items: center;
width: 50px;
height: 50px;
}
input[type="checkbox"] {
width: 100%;
height: 100%;
}
By making the <label> a flex container, the checkbox will stretch to fill available space.
See the Pen
Untitled by retina (@retina99)
on CodePen.
The benefit of this approach is more control over layout and responsiveness. The label can take any width/height.
A minor drawback is it introduces extra markup which some developers prefer to avoid.
Method 4: SVG Checkbox Icon
For the most flexibility, you can forego the native checkbox input and create a custom SVG checkbox icon instead.
Here is an example:
<button class="checkbox">
<svg>
<!-- checkbox icon -->
</svg>
Remember me
</button>
.checkbox {
height: 60px;
width: 60px;
background: #FFF;
border-radius: 6px;
border: 2px solid #AAA;
}
.checkbox svg {
/* size icon */
}
.checkbox:focus {
/* focused style */
}
And handle the checked/unchecked logic and accessibility attributes with JavaScript.
The benefits of using an SVG checkbox are:
- Full control over styling
- Animate and morph the icon
- Theme-able with CSS variables
- No browser differences
- Accessibility friendly
The downside is it requires more code to implement.
Tips for Accessible Checkboxes
When increasing checkbox size or customizing appearance, keep these accessibility tips in mind:
- Retain default
:focusoutline style for keyboard users - Ensure sufficient color contrast ratio
- Add
aria-*attributes for screen readers - Allow selecting via keyboard tab/space
- Support right-click selection for users with motor impairments
Do not only rely on hover or color to signify "checked" state. That creates confusion for anyone not using a mouse.
Responsive Checkbox Sizing
Instead of a fixed size, you may want checkboxes to resize responsively across device sizes.
The best approach is to use relative units like EM or REM for width/height. For example:
input[type="checkbox"] {
width: 2em;
height: 2em;
}
This will scale the checkbox relative to surrounding text size.
You can also use viewport units:
input[type="checkbox"] {
width: 5vw;
height: 5vw;
}
Which sizes based on the viewport width.
Finally, for pixel precision, leverage CSS clamp():
input[type="checkbox"] {
width: clamp(20px, 5vw, 30px);
height: clamp(20px, 5vw, 30px);
}
This keeps the size between 20px and 30px, sizing up responsively in between.
So in summary, use dynamic units, media queries, or clamp() to achieve adaptive checkboxes.
Customize Appearance and Styles
In addition to size, you can customize various styling aspects of checkboxes:
/* Box model */
input[type="checkbox"] {
padding: 12px;
border-radius: 8px;
box-shadow: 0 5px 20px rgba(0,0,0,.2);
background: var(--bg-color);
border: 3px solid var(--border-color);
}
/* Checkmark icon */
input[type="checkbox"]:checked {
background-image: url(check.svg);
background-size: 60% 60%;
background-position: center;
background-repeat: no-repeat;
}
/* Focus, hover etc */
input[type="checkbox"]:focus {
outline-color: var(--accent-color);
}
input[type="checkbox"]:hover {
filter: brightness(95%);
}
Custom properties (CSS variables) are great for theming controls.
You have the full creative freedom to style checkboxes however fits your design system.
Animated and Morphing Checkboxes
For extra pizzazz, animate and morph the checkbox with CSS transitions or keyframe animations.
For example, slide it in when checked:
input[type="checkbox"]::after {
content: ‘‘;
display: block;
width: 20px;
height: 10px;
transform: translateX(200%);
transition: .3s ease transform;
}
input[type="checkbox"]:checked::after {
transform: none;
}
Or create a morphing animation:
@keyframes morph {
0%, 40% {
border-radius: 50%;
transform: rotate(0deg);
}
100% {
border-radius: 4px;
transform: rotate(180deg);
}
}
input[type="checkbox"]:checked {
animation: morph .4s ease forwards;
}
These types of effects can make interactions more lively and engaging. But ensure they don‘t distract or overwhelm users.
Subtle enhancements go a long way.
Cross-Browser Compatibility
When increasing checkbox size or styling, watch for inconsistencies across browsers.
For example, the exact height/width needed to cover the native checkbox icon varies. You may need to add a bit of extra padding or positioning adjustments to square the edges perfectly.
Safari has some unique behavior to be aware of:
- By default checkboxes have
appearance: checkboxstyling which overrides certain properties - The checked indicator color won‘t change from blue
Prefix the CSS accordingly:
input[type="checkbox"] {
-webkit-appearance: none;
}
In some cases you‘ll have to hide the default icon with Clip Path and add a custom SVG icon instead for full customization and control.
So test! Don‘t assume CSS will render pixel-perfect across the spectrum of browsers and devices. Fine-tune as needed.
Conclusion
I hope this post gave you a comprehensive overview of how to control checkbox size in CSS – whether enlarging existing inputs or creating custom animated toggle buttons.
Key takeaways:
- Use width/height, transform or label containers to enlarge
- Ensure accessibility when customizing widgets
- Animate and add flair with CSS transitions and keyframe animations
- Handle browser quirks, especially on Webkit/Safari
- Stick to proven UI patterns users understand
Now you have all the tools to build big beautiful checkboxes! The possibilities are unlimited.
Let me know if you have any other tips or tricks for styling checkbox inputs. I‘m always eager to push CSS to its limits!


