Form Layouts
Forms are structured using a set of flexible container classes that handle spacing, alignment, and validation states. 📝
Examples
Section titled “Examples”Basic Form Structure
Section titled “Basic Form Structure”Use the .ro-form class as the main container for your form. Inside, use .ro-field to wrap each label and control pair: .ro-field-header holds the .ro-field-label, and label.ro-input-group wraps the control. This ensures consistent vertical spacing.
<form class="ro-form ro-u-items-stretch"><div class="ro-field"> <div class="ro-field-header"> <div class="ro-field-label"> <label for="email">Email address</label> </div> </div> <label class="ro-input-group"> <input id="email" class="ro-input" type="email" placeholder="name@example.com" /> </label></div><div class="ro-field"> <div class="ro-field-header"> <div class="ro-field-label"> <label for="password">Password</label> </div> </div> <label class="ro-input-group"> <input id="password" class="ro-input" type="password" placeholder="Password" /> </label></div><button class="ro-btn ro-color-scheme-product">Submit</button></form>Required, Description, and Error
Section titled “Required, Description, and Error”To display validation errors, add .ro-state-invalid to the .ro-field and include a .ro-field-error element. The error message is only visible when the field has the invalid state class.
<div class="ro-field ro-state-invalid"><div class="ro-field-header"> <div class="ro-field-label"> <label for="company-field"> Company <span class="ro-field-required-indicator" aria-hidden="true">*</span> </label> </div> <div class="ro-label-description">Visible on your public profile</div></div><label class="ro-input-group"> <input id="company-field" class="ro-input" type="text" placeholder="Acme Inc." aria-required="true" aria-invalid="true" /></label><span class="ro-field-error" role="alert"> <i class="ro-icon ro-icon-warning-error" aria-hidden="true"></i> Company name is required</span></div>Company name is required
Horizontal Fields in a Form
Section titled “Horizontal Fields in a Form”Add .ro-dir-horizontal to .ro-field and stack several fields inside .ro-form. Use .ro-divider to separate groups — this works well for settings panels where the label and control sit on one row.
<form class="ro-form"><div class="ro-field ro-dir-horizontal"> <div class="ro-field-label"> <label for="notify-email">Email notifications</label> </div> <input type="checkbox" class="ro-switch" id="notify-email" checked /></div><div class="ro-field ro-dir-horizontal"> <div class="ro-field-label"> <label for="notify-push">Push notifications</label> </div> <input type="checkbox" class="ro-switch" id="notify-push" /></div><hr class="ro-divider" /><div class="ro-field ro-dir-horizontal"> <div class="ro-field-label"> <label for="profile-visibility">Profile visibility</label> </div> <input type="checkbox" class="ro-switch" id="profile-visibility" checked /></div><hr class="ro-divider" /><div class="ro-field ro-dir-horizontal"> <div class="ro-field-label"> <label for="usage-analytics">Usage analytics</label> </div> <input type="checkbox" class="ro-switch" id="usage-analytics" /></div></form>Complex Layouts (Grid)
Section titled “Complex Layouts (Grid)”For multi-column layouts, combine .ro-form with Grid utilities — for example .ro-grid with responsive column classes.
<form class="ro-form"><div class="ro-grid ro-cols-1 md:ro-cols-2 ro-u-gap-4"> <div class="ro-field"> <div class="ro-field-header"> <div class="ro-field-label"> <label for="fname">First Name</label> </div> </div> <label class="ro-input-group"> <input id="fname" class="ro-input" type="text" placeholder="Jane" /> </label> </div> <div class="ro-field"> <div class="ro-field-header"> <div class="ro-field-label"> <label for="lname">Last Name</label> </div> </div> <label class="ro-input-group"> <input id="lname" class="ro-input" type="text" placeholder="Doe" /> </label> </div> <div class="ro-field ro-col-span-1 md:ro-col-span-2"> <div class="ro-field-header"> <div class="ro-field-label"> <label for="address">Address</label> </div> </div> <label class="ro-input-group"> <input id="address" class="ro-input" type="text" placeholder="123 Main St" /> </label> </div></div><button class="ro-btn ro-color-scheme-product ro-u-self-end"><i class="ro-icon ro-icon-check-circle"></i>Save Profile</button></form>Option Groups
Section titled “Option Groups”Use .ro-radio-group or .ro-checkbox-group to group related options. Use .ro-input-option for a single checkbox, radio, or switch row.
Radio Group
Section titled “Radio Group”<fieldset class="ro-radio-group"><legend>Preferences</legend><label class="ro-input-option"> <input type="radio" class="ro-input-radio" name="pref" checked /> Option 1</label><label class="ro-input-option"> <input type="radio" class="ro-input-radio" name="pref" /> Option 2</label></fieldset>Checkbox Group
Section titled “Checkbox Group”Add .ro-dir-horizontal on the group for a wrapping horizontal layout.
<fieldset class="ro-checkbox-group"><legend>Notifications</legend><label class="ro-input-option"> <input type="checkbox" class="ro-input-checkbox" checked /> Email alerts</label><label class="ro-input-option"> <input type="checkbox" class="ro-input-checkbox" /> Push notifications</label></fieldset>Properties
Section titled “Properties”| Class | Description |
|---|---|
.ro-form | Main container for forms. Vertical stack with var(--ro-size-4) gap. |
.ro-form-section | Nested form grouping (layout stack only; no built-in title styles). |
.ro-field | Wrapper for a label and control pair. Legacy alias: .ro-form-control. |
.ro-field-input | Tighter gap between label and control. |
.ro-field-header | Holds the label and optional .ro-label-description. |
.ro-field-label | Label styling. Legacy alias: .ro-label. |
.ro-field-error | Error message (visible when the field is invalid). Legacy alias: .ro-form-error-message. |
.ro-dir-horizontal | Horizontal label/control layout on .ro-field. |
.ro-state-invalid | Shows error messages; danger border on inputs, counters, and selects. |
.ro-radio-group, .ro-checkbox-group | Option groups with reset fieldset chrome. |
.ro-input-option | Single checkbox, radio, or switch row. |
Changelog
Recent updates in @ringover/styles. See the full
package changelog
.
-
- Updated form elements and inputs HTML structure.