Forms obtain user data and transmit it to the system to either store the data, produce an action, or both.

installyarn add @clayui/form
versionNPM Version
useimport ClayForm, {ClayInput} from '@clayui/form';

Table of Contents

Don’t forget to check WAI-ARIA accessibility pratices for Form Elements when writting your markup.

The .form-group class is the easiest way to add some structure to forms. It provides a flexible class that encourages proper grouping of labels, controls, optional help text, and form validation messaging. By default it only applies margin-bottom, but it picks up additional styles in .form-inline as needed. Use it with <fieldset>s, <div>s, or nearly any other element.

Snippet

Autofit

Equally spaced form inputs based on the number of items inside .form-group-autofit. Each input and label group should be wrapped inside .form-group-item. form-group-autofit stacks all inputs at max-width: 575px (breakpoint sm).

To set a maximum width on a .form-group-item use max-width: 200px;.

To make a .form-group-item shrink to the size of its content add .form-group-item-shrink. This component should only be used for static content, such as labels or buttons. This component doesn’t work well with dynamically added content, such as form helper text, use the max-width method above instead.

Form Group Autofit doesn’t support label’s with long text that breaks to new lines or multiple new lines above the input.
$
.00
$
.00

Snippet

Horizontal

Create horizontal forms by placing each input inside form-group-item and label inside form-group-item form-group-item-label form-group-item-shrink and set a min-width on .form-group-item-label.

Snippet

Edit this page on GitHub

Contributors

Matuzalém Teles

Last edited May 9, 2025 at 6:15:38 AM

Table of Contents