Tag Archives: custom checkbox

Skinnable CSS3 Metro Forms

Try Semtex – the new HTML5, CSS3 and JavaScript UI framework!

Say hi to AcidJs.Forms, the successor of one of the oldest components in Acid.JS Web.UI – Forms.JS!

AcidJs.Forms is a powerful component that will give you total control over the form elements on your page without any additional markup or sophisticated JavaScript. The component will seamlessly add cool metro looks to input boxes, buttons, file inputs, checkboxes, radiobuttons and dropdowns.

acidjs-forms

Key Features
  • Lightweight and imageless, fully CSS3-driven skins.
  • Fast initialization and small footprint.
  • CSS3 animations and transitions.
  • Support for themes.
  • Rich client API and custom events.
  • Support for multiple themes on a single page.
  • No additional markup required.
  • The full version is shipped with 5 ready to use themes (Default, Gray, Orange, Red and Violet).
  • Fallback for non-CSS3 browsers.

Check the info here, look at the demo and have fun!

Imageless Custom Checkboxes and Radio Buttons with CSS3: Revisited

I’ve always been interested in techniques for adding custom look and feel to form elements, and through the years I’ve offered a number of such solutions. In today’s post I will share my latest insight in check box and radio button styling, which is an improved version of another technique I’ve offered sometime ago, but this time with a fallback for non-CSS3 browsers and more elegant looks and code.

css-pages-imageless-css3-custom-checkboxes-and-radio-buttons

The CSS

As you can see, I am using the CSS3 :root element, which is ignored by non-CSS3 browsers, so they will display the normal check boxes and radios. The code listing below contains only official CSS properties, so maybe it’s a good idea to download the cross-browser solution from this link.

:root .css3-radios label,
:root .css3-radios input[type="radio"] + span,
:root .css3-radios input[type="radio"] + span::before,
:root .css3-checkboxes label,
:root .css3-checkboxes input[type="checkbox"] + span,
:root .css3-checkboxes input[type="checkbox"] + span::before
{
    display: inline-block;
    vertical-align: middle;
}

:root .css3-radios,
:root .css3-checkboxes
{
    position: relative;
}

:root .css3-radios label *,
:root .css3-checkboxes label *
{
    cursor: pointer;
}

:root .css3-radios input[type="radio"],
:root .css3-checkboxes input[type="checkbox"]
{
    opacity: 0;
    position: absolute;
}

:root .css3-radios input[type="radio"] + span,
:root .css3-checkboxes input[type="checkbox"] + span
{
    font: normal 11px/14px Arial, Sans-serif;
    color: #333;
}

:root .css3-radios label:hover span::before,
:root .css3-checkboxes label:hover span::before
{
    box-shadow: 0 0 2px #ccc;
}

:root .css3-radios label:hover span,
:root .css3-checkboxes label:hover span
{
    color: #000;
}

:root .css3-radios input[type="radio"] + span::before,
:root .css3-checkboxes input[type="checkbox"] + span::before
{
    content: "";
    width: 12px;
    height: 12px;
    margin: 0 4px 0 0;
    border: solid 1px #a8a8a8;
    line-height: 14px;
    text-align: center;
    border-radius: 100%;
    background: #f6f6f6;
    background: radial-gradient(#f6f6f6, #dfdfdf);
}

:root .css3-radios input[type="radio"]:checked + span::before,
:root .css3-checkboxes input[type="checkbox"]:checked + span::before
{
    color: #666;
}

:root .css3-radios input[type="radio"]:disabled + span,
:root .css3-checkboxes input[type="checkbox"]:disabled + span
{
    cursor: default;
    opacity: .4;
}

:root .css3-checkboxes input[type="checkbox"] + span::before
{
    border-radius: 2px;
}

:root .css3-radios input[type="radio"]:checked + span::before
{
    content: "2022";
    font-size: 24px;
}

:root .css3-checkboxes input[type="checkbox"]:checked + span::before
{
    content: "2714";
    font-size: 12px;
}

The Markup

Nothing fancy here, just a regular semantic form without any additional markup, supporting natively keyboard navigation and accessibility intact.

<!-- markup for custom radio buttons -->
<ul class="css3-radios">
    <li><label><input type="radio" checked="checked" name="radios-01" /><span>checked radio button</span></label></li>
    <li><label><input type="radio" name="radios-01" /><span>unchecked radio button</span></label></li>
    <li><label><input type="radio" name="radios-01" disabled="disabled" /><span>disabled radio button</span></label></li>
</ul>
<!-- / markup for custom radio buttons -->
<!-- markup for custom check boxes -->
<ul class="css3-checkboxes">
    <li><label><input type="checkbox" checked="checked" name="checkbox-01" /><span>selected checkbox</span></label></li>
    <li><label><input type="checkbox" name="checkbox-02" /><span>unselected checkbox</span></label></li>
    <li><label><input type="checkbox" name="checkbox-03" disabled="disabled" /><span>disabled checkbox</span></label></li>
</ul>
<!-- / markup for custom check boxes -->

What do you Think?

If you like the solution, you can try the demo or get it from this link. In case you are interested in other stuff I do, you can follow me on Twitter, visit my personal website or check my Web UI components.

Have a great weekend!

Related Posts

Imageless CSS3 Custom Checkboxes and Radio Buttons

This solution is outdated. You can find the newest one on this page. Find more experiments here.

css-pages-imageless-css3-custom-checkboxes-and-radio-buttons

Related Posts

Custom Crossbrowser Styling for Checkboxes and Radio Buttons

This solution is outdated. You can find the newest one on this page. Find more experiments here.

More Cool Stuff

The New Killer Version of Forms.JS Form Element Skinning Component is Out

Forms.JS is a powerful component that will give you total control over the form elements on your page without any additional markup or sophisticated JavaScript. All you have to do is to add a single line of JavaScript in the head section of your webpage, define which elements will be styled, specify skinning region, set a skin, reload the page and leave the rest to Forms.JS. The component will seamlessly add cool Web 2.0 looks to input boxes, buttons, file inputs, checkboxes, radiobuttons and dropdowns.

What’s New in the Latest Version

  • Automatic styling of dynamically added form elements in the specified region.
  • Just one image sprite per skin and extensive use of CSS3.
  • Faster and seamless initialization.
  • Optional CSS3 support for IE7 and IE8 via CSS3Pie.
  • Internet Explorer 9 ready.
  • Selectboxes animations.
  • Built on top of jQuery.
  • New set of skins.
  • Improved client API.
  • Support for for the size property of selectboxes (expanded dropdowns).
  • Platform-independable – PHP, .NET, JAVA, etc.
  • Multiple skins on a single page.
  • Additional markup not required – just your form elements.

Check out the demo? And maybe download? Forms.JS 4.0 is also available in the latest version of Acid.JS Web 2.0 Component Library.