This section demonstrates the different text input types.

installyarn add @clayui/form
versionNPM Version
useimport {ClayCheckbox} from '@clayui/form';

Example

Snippet

Be sure to use an appropriate type attribute on all inputs (e.g., email for email address or number for numerical information) to take advantage of newer input controls like email verification, number selection, and more.

Disabled

Add the disabled boolean attribute on an input to prevent user interactions and make it appear lighter.

Snippet

Readonly

Add the readonly boolean attribute on an input to prevent modification of the input’s value. Read-only inputs appear lighter (just like disabled inputs), but retain the standard cursor.

Snippet

Sizes

Set heights using classes like .form-control-lg and .form-control-sm.

Snippet

Textarea

Snippet

Validations

Success

Snippet

Warning

Snippet

Error

Snippet

HTML 5 Validations

The browser default form validation. Submit the form to see it in action.

Please enter letters only.
Please enter numbers only.

Novalidate Attribute

The novalidate attribute on the form element will disable the browser’s default validation tooltip. This allows us to display custom validation text while taking advantage of the browser’s built in form validation API.

You will need to prevent form submission if there are invalid fields by using the HTMLInputElement.checkValidity() method.

Snippet

The was-validated class on the form element displays the success or error messages for :valid and :invalid fields. It should be added when the form is submitted. Documentation on HTML5 form validation attributes can be found on MDN.

This is correct!
Please enter letters only.
Please enter numbers only.
Please enter a valid city.
Please select a state.
Please enter a valid zip code.

Snippet

Edit this page on GitHub

Contributors

Matuzalém Teles

Last edited May 12, 2025 at 7:56:02 PM