Support CoreUI Development

CoreUI is an MIT-licensed open source project and is completely free to use. However, the amount of effort needed to maintain and develop new features for the project is not sustainable without proper financial backing.

You can support our Open Source software development in the following ways:

  • Buy the CoreUI PRO, and get access to PRO components, and dedicated support.
  • Became a sponsor, and get your logo on files or each site of this documentation
  • Give us a star ⭐️ on Github.

React Form Layout

Give your forms some structure—from inline to horizontal to custom grid implementations—with our form layout options.


Every group of form fields should reside in a <CForm> element. CoreUI provides no default styling for the <CForm> element, but there are some powerful browser features that are provided by default.

  • New to browser forms? Consider reviewing the MDN form docs for an overview and complete list of available attributes.
  • <CButton>s within a <CForm> default to type="submit", so strive to be specific and always include a type.
  • You can disable every form element within a form with the disabled attribute on the <CForm>.

Since CoreUI applies display: block and width: 100% to almost all our form controls, forms will by default stack vertically. Additional classes can be used to vary this layout on a per-form basis.


Margin utilities are the easiest way to add some structure to forms. They provide basic grouping of labels, controls, optional form text, and form validation messaging. We recommend sticking to margin-bottom utilities, and using a single direction throughout the form for consistency.

Form grid#

More complex forms can be built using our grid classes. Use these for form layouts that require multiple columns, varied widths, and additional alignment options.

2 <CCol xs>
3 <CFormInput placeholder="First name" aria-label="First name"/>
4 </CCol>
5 <CCol xs>
6 <CFormInput placeholder="Last name" aria-label="Last name"/>
7 </CCol>


By adding gutter modifier classes, you can have control over the gutter width in as well the inline as block direction.

1<CRow className="g-3">
2 <CCol xs>
3 <CFormInput placeholder="First name" aria-label="First name"/>
4 </CCol>
5 <CCol xs>
6 <CFormInput placeholder="Last name" aria-label="Last name"/>
7 </CCol>

More complex layouts can also be created with the grid system.

1<CForm className="row g-3">
2 <CCol md={6}>
3 <CFormInput type="email" id="inputEmail4" label="Email" />
4 </CCol>
5 <CCol md={6}>
6 <CFormInput type="password" id="inputPassword4" label="Password" />
7 </CCol>
8 <CCol xs={12}>
9 <CFormInput id="inputAddress" label="Address" placeholder="1234 Main St"/>
10 </CCol>
11 <CCol xs={12}>
12 <CFormInput id="inputAddress2" label="Address 2" placeholder="Apartment, studio, or floor"/>
13 </CCol>
14 <CCol md={6}>
15 <CFormInput id="inputCity" label="City"/>
16 </CCol>
17 <CCol md={4}>
18 <CFormSelect id="inputState" label="State">
19 <option>Choose...</option>
20 <option>...</option>
21 </CFormSelect>
22 </CCol>
23 <CCol md={2}>
24 <CFormInput id="inputZip" label="Zip" />
25 </CCol>
26 <CCol xs={12}>
27 <CFormCheck type="checkbox" id="gridCheck" label="Check me out"/>
28 </CCol>
29 <CCol xs={12}>
30 <CButton type="submit">Sign in</CButton>
31 </CCol>

Horizontal form#

Create horizontal forms with the grid by adding the .row class to form groups and using the .col-*-* classes to specify the width of your labels and controls. Be sure to add .col-form-label to your <CFormLabel>s as well so they're vertically centered with their associated form controls.

At times, you maybe need to use margin or padding utilities to create that perfect alignment you need. For example, we've removed the padding-top on our stacked radio inputs label to better align the text baseline.

2 <CRow className="mb-3">
3 <CFormLabel htmlFor="inputEmail3" className="col-sm-2 col-form-label">Email</CFormLabel>
4 <CCol sm={10} >
5 <CFormInput type="email" id="inputEmail3"/>
6 </CCol>
7 </CRow>
8 <CRow className="mb-3">
9 <CFormLabel htmlFor="inputPassword3" className="col-sm-2 col-form-label">Password</CFormLabel>
10 <CCol sm={10} >
11 <CFormInput type="password" id="inputPassword3"/>
12 </CCol>
13 </CRow>
14 <fieldset className="row mb-3">
15 <legend className="col-form-label col-sm-2 pt-0">Radios</legend>
16 <CCol sm={10} >
17 <CFormCheck type="radio" name="gridRadios" id="gridRadios1" value="option1" label="First radio" defaultChecked/>
18 <CFormCheck type="radio" name="gridRadios" id="gridRadios2" value="option2" label="Second radio"/>
19 <CFormCheck type="radio" name="gridRadios" id="gridRadios3" value="option3" label="Third disabled radio" disabled/>
20 </CCol>
21 </fieldset>
22 <CRow className="mb-3">
23 <div className="col-sm-10 offset-sm-2">
24 <CFormCheck type="checkbox" id="gridCheck1" label="Example checkbox"/>
25 </div>
26 </CRow>
27 <CButton type="submit">Sign in</CButton>

Horizontal form label sizing#

Be sure to use .col-form-label-sm or .col-form-label-lg to your <CFormLabel>s or <legend>s to correctly follow the size of .form-control-lg and .form-control-sm.

1<CRow className="mb-3">
2 <CFormLabel htmlFor="colFormLabelSm" className="col-sm-2 col-form-label col-form-label-sm">Email</CFormLabel>
3 <CCol sm={10} >
4 <CFormInput type="email" className="form-control form-control-sm" id="colFormLabelSm" placeholder="col-form-label-sm"/>
5 </CCol>
7<CRow className="mb-3">
8 <CFormLabel htmlFor="colFormLabel" className="col-sm-2 col-form-label">Email</CFormLabel>
9 <CCol sm={10} >
10 <CFormInput type="email" id="colFormLabel" placeholder="col-form-label"/>
11 </CCol>
14 <CFormLabel htmlFor="colFormLabelLg" className="col-sm-2 col-form-label col-form-label-lg">Email</CFormLabel>
15 <CCol sm={10} >
16 <CFormInput type="email" className="form-control form-control-lg" id="colFormLabelLg" placeholder="col-form-label-lg"/>
17 </CCol>

Column sizing#

As shown in the previous examples, our grid system allows you to place any number of <CCol>s within a <CRow>. They'll split the available width equally between them. You may also pick a subset of your columns to take up more or less space, while the remaining <CCol>s equally split the rest, with specific column classes like <CCol sm={7} >.

1<CRow className="g-3">
2 <CCol sm={7} >
3 <CFormInput placeholder="City" aria-label="City"/>
4 </CCol>
5 <CCol sm>
6 <CFormInput placeholder="State" aria-label="State"/>
7 </CCol>
8 <CCol sm>
9 <CFormInput placeholder="Zip" aria-label="Zip"/>
10 </CCol>


The example below uses a flexbox utility to vertically center the contents and changes <CCol> to <CCol xs="auto"> so that your columns only take up as much space as needed. Put another way, the column sizes itself based on the contents.

1<CForm className="row gy-2 gx-3 align-items-center">
2 <CCol xs="auto">
3 <CFormLabel className="visually-hidden" htmlFor="autoSizingInput">Name</CFormLabel>
4 <CFormInput id="autoSizingInput" placeholder="Jane Doe"/>
5 </CCol>
6 <CCol xs="auto">
7 <CFormLabel className="visually-hidden" htmlFor="autoSizingInputGroup">Username</CFormLabel>
8 <CInputGroup>
9 <CInputGroupText>@</CInputGroupText>
10 <CFormInput id="autoSizingInputGroup" placeholder="Username"/>
11 </CInputGroup>
12 </CCol>
13 <CCol xs="auto">
14 <CFormLabel className="visually-hidden" htmlFor="autoSizingSelect">Preference</CFormLabel>
15 <CFormSelect id="autoSizingSelect">
16 <option>Choose...</option>
17 <option value="1">One</option>
18 <option value="2">Two</option>
19 <option value="3">Three</option>
20 </CFormSelect>
21 </CCol>
22 <CCol xs="auto">
23 <CFormCheck type="checkbox" id="autoSizingCheck" label="Remember me"/>
24 </CCol>
25 <CCol xs="auto">
26 <CButton type="submit">Submit</CButton>
27 </CCol>

You can then remix that once again with size-specific column classes.

1<CForm className="row gx-3 gy-2 align-items-center">
2 <CCol sm={3} >
3 <CFormLabel className="visually-hidden" htmlFor="specificSizeInputName">Name</CFormLabel>
4 <CFormInput id="specificSizeInputName" placeholder="Jane Doe"/>
5 </CCol>
6 <CCol sm={3} >
7 <CFormLabel className="visually-hidden" htmlFor="specificSizeInputGroupUsername">Username</CFormLabel>
8 <CInputGroup>
9 <CInputGroupText>@</CInputGroupText>
10 <CFormInput id="specificSizeInputGroupUsername" placeholder="Username"/>
11 </CInputGroup>
12 </CCol>
13 <CCol sm={3} >
14 <CFormLabel className="visually-hidden" htmlFor="specificSizeSelect">Preference</CFormLabel>
15 <CFormSelect id="specificSizeSelect">
16 <option>Choose...</option>
17 <option value="1">One</option>
18 <option value="2">Two</option>
19 <option value="3">Three</option>
20 </CFormSelect>
21 </CCol>
22 <CCol xs="auto">
23 <CFormCheck type="checkbox" id="autoSizingCheck2" label="Remember me"/>
24 </CCol>
25 <CCol xs="auto">
26 <CButton type="submit">Submit</CButton>
27 </CCol>

Inline forms#

Use the <CCol xs="auto"> class to create horizontal layouts. By adding gutter modifier classes, we will have gutters in horizontal and vertical directions. The .align-items-center aligns the form elements to the middle, making the <CFormCheck> align properly.

1<CForm className="row row-cols-lg-auto g-3 align-items-center">
2 <CCol xs={12}>
3 <CFormLabel className="visually-hidden" htmlFor="inlineFormInputGroupUsername">Username</CFormLabel>
4 <CInputGroup>
5 <CInputGroupText>@</CInputGroupText>
6 <CFormInput id="inlineFormInputGroupUsername" placeholder="Username"/>
7 </CInputGroup>
8 </CCol>
10 <CCol xs={12}>
11 <CFormLabel className="visually-hidden" htmlFor="inlineFormSelectPref">Preference</CFormLabel>
12 <CFormSelect id="inlineFormSelectPref">
13 <option>Choose...</option>
14 <option value="1">One</option>
15 <option value="2">Two</option>
16 <option value="3">Three</option>
17 </CFormSelect>
18 </CCol>
20 <CCol xs={12}>
21 <CFormCheck type="checkbox" id="inlineFormCheck" label="Remember me"/>
22 </CCol>
24 <CCol xs={12}>
25 <CButton type="submit">Submit</CButton>
26 </CCol>