Semantic UI Form
Semantic UI Form is a versatile component that provides an easy and flexible way to collect and validate user input.
Syntax
<form class="ui form">
<!-- Form fields and buttons go here -->
</form>
Example
<form class="ui form">
<div class="field">
<label>Name</label>
<input type="text" name="name" placeholder="Enter your name">
</div>
<div class="field">
<label>Email</label>
<input type="email" name="email" placeholder="Enter your email">
</div>
<button class="ui button" type="submit">Submit</button>
</form>
Output
Explanation
- The
ui form
class is applied to create a form container. - Form fields are represented by the
field
class. - Each field typically includes a
label
and an input element such asinput
,textarea
, orselect
. - The
ui button
class is used for styling the submit button.
Use
Semantic UI Form is used whenever you need to collect user input, such as in registration forms, login forms, or any other data entry scenarios. It provides a clean and consistent way to structure and style forms.
Important Points
- Customize the form layout by using different field types and arranging them as needed.
- Add validation rules using Semantic UI classes or include custom JavaScript validation.
- Use additional classes like
loading
to indicate that the form is processing.
<form class="ui form loading">
<!-- Form fields and buttons go here -->
</form>
Summary
Semantic UI Form simplifies the process of creating interactive and visually appealing forms. Its flexibility and ease of use make it a go-to choice for developers building applications or websites that require user input. Tailor the form to meet your specific requirements, and consider incorporating validation for a seamless user experience.