FORM GROUP: Reusable form layout patterns
COMPOSES: .form-label | .form-control | .form-select | .form-text | .invalid-feedback
Form groups compose labels, inputs, helper text, and validation messages into consistent, reusable layouts. Choose the layout that best fits your form's context: vertical for standard forms, horizontal for settings panels, inline for compact search/filters, or floating for modern minimal interfaces.
Vertical: The standard form layout with labels stacked above inputs. Best for most forms, especially on mobile devices and when label text varies in length.
<div class="tw-form-group"> <label class="tw-form-label">Label</label> <input class="tw-form-control"> <span class="tw-form-text">Helper text</span></div>
Horizontal: Labels positioned beside inputs, ideal for settings forms, admin panels, and when you have consistent short labels. The label aligns with the input's text baseline.
Label with different input sizes
Small input
Default input
Large input
Label Width Variants
Small label (6rem)
Default label (8rem)
Large label (12rem)
<div class="tw-form-group-horizontal"> <label class="tw-form-label">Label</label> <input class="tw-form-control"></div>Label widths: .label-sm (6rem) | default (8rem) | .label-lg (12rem) | .label-auto
Inline: Multiple form groups arranged horizontally in a row. Perfect for search bars, filter controls, and compact data entry. Groups automatically flex to fill available space.
Search Bar
Filter Controls
Date Range
<div class="tw-form-inline"> <div class="tw-form-group">...</div> <div class="tw-form-group">...</div> <div class="tw-form-group-fixed">...</div></div>Use .form-group-fixed for buttons/fixed-width elements
Floating: Modern minimal design where the label floats inside the input and animates up on focus or when a value is entered. Requires placeholder=" " (space) for the CSS to detect empty state.
Floating Labels with Values
<div class="tw-form-floating"> <input class="tw-form-control" placeholder=" "> <label class="tw-form-label">Label</label></div>Note: Input must come BEFORE label. Use placeholder=" " (space) for empty state detection.
Form Row: Multi-column form layouts using a flexible grid system. Columns automatically stack on mobile. Use column width classes to control proportions.
Two Columns (50/50)
Three Columns (33/33/33)
Mixed Widths (Auto + Fixed)
<div class="tw-form-row"> <div class="tw-form-group tw-form-group-col-6">...</div> <div class="tw-form-group tw-form-group-col-6">...</div></div>Columns: .form-group-col-12 (full) | .form-group-col-6 (half) | .form-group-col-4 (third) | .form-group-col-3 (quarter) | .form-group-col-auto (flex)
Form Sections: Group related fields together with a title and optional description. Sections have visual separation via borders.
Enter your personal details as they appear on official documents.
How can we reach you?
<div class="tw-form-section"> <h3 class="tw-form-section-title">Section Title</h3> <p class="tw-form-section-description">Description text</p> <div class="tw-form-group">...</div></div>
Validation: Form groups work seamlessly with validation states. Error and success messages appear below the input in all layout types.
Vertical Layout
Horizontal Layout
Floating Labels
Compact: Use .form-group-sm for reduced spacing between form groups, ideal for dense forms or modal dialogs.
<div class="tw-form-group-sm">...</div>
Complete Example: A registration form combining multiple layout patterns for a polished user experience.
Quick Reference
Vertical Layout: .form-group
Horizontal Layout: .form-group-horizontal | .label-sm | .label-lg | .label-auto
Inline Forms: .form-inline > .form-group | .form-group-fixed | .form-group-auto
Floating Labels: .form-floating (input before label, placeholder=" ")
Form Row: .form-row > .form-group-col-12 | .form-group-col-6 | .form-group-col-4 | .form-group-col-3 | .form-group-col-auto
Form Sections: .form-section > .form-section-title + .form-section-description
Compact Spacing: .form-group-sm
Horizontal Input Wrapper: .form-group-input (for helper text/feedback in horizontal)