--- title: Forms path: components/forms status: Stable source: 'https://github.com/primer/css/tree/master/src/forms' bundle: forms --- Style individual form controls and utilize common layouts. Overview: - We reset several elements' default styles for cross browser consistency and easier manipulation later. This includes `
`s, WebKit validation bubbles, and most textual ``s. - Specific types of textual ``s are styled automatically, but `.form-control` is available should you need it. - Always declare a `type` on your `

``` #### Example form Form controls in Primer CSS currently have no basic layout specified (this is by design). You'll need to use `
`s, `
`s, or other elements and styles to rearrange them. ```html live
``` #### Form contrast Textual form controls have a white background by default. You can change this to a light gray with `.input-contrast`. ```html live
``` #### Disabled state Add the `disabled` attribute to make a `.form-control` appear disabled. ```html live
``` #### Sizing Make inputs smaller, larger, or full-width with an additional class. ##### Small ```html live
``` ##### Large ```html live
``` ##### Block ```html live
``` ##### Dark ```html live
``` ##### Hide webkit's contact info autofill icon Webkit sometimes gets confused and tries to add an icon/dropdown to autofill contact information on fields that may not be appropriate (such as input for number of users). Use this class to override the display of this icon. ```html live
``` #### Selects Primer CSS adds light `height` and `vertical-align` styles to ` ``` ##### Small Use the `.select-sm` class to resize both default and custom ` ``` #### Form groups ```html live
``` #### Form group validation Convey success, errors and warnings for form groups. For github.com consider using the [``](https://github.github.io/web-systems-documentation/#custom-elements-auto-check-md) element to perform server-side validation on an input. If the input is **valid**, add the `.successed` class to the `
` element. Next add/update a success message to the `.note` element, as well as the `.success` class. ```html live

monalisa is available

``` If the input is **not valid**, add the `.errored` class to the `
` element. Next add/update an error message to the `.note` element, as well as the `.error` class. ```html live

monalisa is not available. monalisa-beep, monalisa-cyber, or monalisa87 are available.

``` If the input should show a **warning**, add the `.warn` class to the `
` element. Next add/update a warning message to the `.note` element, as well as the `.warning` class. ```html live

36 of maximum 39 characters entered.

``` #### Checkboxes and radios Utilities to spice up the alignment and styling of checkbox and radio controls. ```html live

This will do insanely awesome and amazing things!

``` You may also add emphasis to the label: ```html live
``` ##### Show / hide content based on a checkbox or radio button state Content that is hidden by default should only be done so if it is non-essential for the context of the surrounding content. Be sure to use the `aria-live="polite"` attribute on the parent label for added content to be announced when displayed. ```html live
``` #### Radio group Radio groups are tab like controls. Their blue border gives extra emphasis to what is selected. ```html live
``` #### Input group Attached an input and button to one another. ```html live
``` #### Form actions Align buttons to the right—via `float: right` on the buttons—in forms with `.form-actions`. The floats are automatically cleared for you. ```html live
```