Halloween Sale 15% off Ends in See the plans
SCSS

Consistent Form Field Styling (SCSS)

Gives text inputs, selects, text areas and checkboxes across the site (comments, contact forms, checkout) one consistent, accessible look with clear focus states.

Don’t have WPIDE yet? Install it on your site

Code

$field-border: #8c8f94;
$field-radius: 6px;
$field-focus: #2271b1;
$field-bg: #ffffff;
$field-padding: .6em .8em;

input[type="text"],
input[type="email"],
input[type="url"],
input[type="tel"],
input[type="number"],
input[type="password"],
input[type="search"],
input[type="date"],
select,
textarea {
    width: 100%;
    max-width: 100%;
    padding: $field-padding;
    border: 1px solid $field-border;
    border-radius: $field-radius;
    background: $field-bg;
    font: inherit;
    line-height: 1.4;
    transition: border-color .15s ease, box-shadow .15s ease;

    &:focus {
        border-color: $field-focus;
        box-shadow: 0 0 0 3px rgba($field-focus, .2);
        outline: none;
    }

    &:disabled {
        background: darken($field-bg, 4%);
        cursor: not-allowed;
    }
}

input[type="checkbox"],
input[type="radio"] {
    width: 1.1em;
    height: 1.1em;
    accent-color: $field-focus;
    vertical-align: middle;
}

label {
    font-weight: 600;
}

Notes

Change the variables at the top. Some form plugins add their own styles with higher specificity.

How to add this snippet

  1. Install WPIDE on your WordPress site (it is free) and open Code Snippets.
  2. Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
  3. It is added inactive: review the code and settings, then switch it on.

Have a snippet worth sharing?

Publish it to the library from WPIDE or right here. Sign in with any WordPress site that runs WPIDE, free or Pro. Public snippets are reviewed by the WPIDE team before they appear.

Which site should get this snippet?

Enter the address of your WordPress site. WPIDE opens there in a new tab with the snippet ready to review and save.

Remembered in this browser only, so you are asked once.

Report this snippet

Tell the WPIDE team what is wrong: broken code, something harmful, spam or copied work.