OCUI Forms

General Rules

Forms are always rendered as .form-horizontal. Field length is justified within the grid. Forms may contain <fieldset>, <hr> separators and intersecting <h2><h4>headlines, but these should be used sparingly, and only if necessary. Each form always has a headline, a gridded set of fields and a .form-submit below the form content, with at least one submit action.

Form Submit

Each form has at least one form-submit component located at its bottom end. A redundant form-submit may be placed on top of the form if the form is either very long or may be sumbitted without change. Use wisely!

Buttons are classed and sorted by importance / likeliness of usage. Each Form has one (!) primary action/submit, and may have several secondary actions, as well as a tertiary abort / cancel action. Order is right aligned, from primary (right) to tertiary (left)

Form Heading

					
					
				






Use The Grid, Luke

Make sure to use an appropriate amount of columns keeping minimum field lengths and label sizes in mind.

Don't Reduce Fields to Content Size

It is often requested to have field length match the content dimensions. This is not recommended with bootstrap forms, as they are designed to work as justified/block level objects in columns.

Form Heading

Form Heading



BS 3.3 Forms

Basic example

Individual form controls automatically receive some global styling. All textual <input>, <textarea>, and <select> elements with .form-control are set to width: 100%; by default. Wrap labels and controls in .form-group for optimum spacing.

Example block-level help text here.

<form>
			<div class="form-group">
			<label for="exampleInputEmail1">Email address</label>
			<input type="email" class="form-control" id="exampleInputEmail1" placeholder="Email">
			</div>
			<div class="form-group">
			<label for="exampleInputPassword1">Password</label>
			<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
			</div>
			<div class="form-group">
			<label for="exampleInputFile">File input</label>
			<input type="file" id="exampleInputFile">
			<p class="help-block">Example block-level help text here.</p>
			</div>
			<div class="checkbox">
			<label>
			<input type="checkbox"> Check me out
			</label>
			</div>
			<button type="submit" class="btn btn-default">Submit</button>
			</form>

Don't mix form groups with input groups

Do not mix form groups directly with input groups. Instead, nest the input group inside of the form group.

Inline form

Add .form-inline to your form (which doesn't have to be a <form>) for left-aligned and inline-block controls. This only applies to forms within viewports that are at least 768px wide.

May require custom widths

Inputs and selects have width: 100%; applied by default in Bootstrap. Within inline forms, we reset that to width: auto; so multiple controls can reside on the same line. Depending on your layout, additional custom widths may be required.

Always add labels

Screen readers will have trouble with your forms if you don't include a label for every input. For these inline forms, you can hide the labels using the .sr-only class. There are further alternative methods of providing a label for assistive technologies, such as the aria-label, aria-labelledby or title attribute. If none of these is present, screen readers may resort to using the placeholder attribute, if present, but note that use of placeholder as a replacement for other labelling methods is not advised.

<form class="form-inline">
			<div class="form-group">
			<label for="exampleInputName2">Name</label>
			<input type="text" class="form-control" id="exampleInputName2" placeholder="Jane Doe">
			</div>
			<div class="form-group">
			<label for="exampleInputEmail2">Email</label>
			<input type="email" class="form-control" id="exampleInputEmail2" placeholder="[email protected]">
			</div>
			<button type="submit" class="btn btn-default">Send invitation</button>
			</form>
<form class="form-inline">
			<div class="form-group">
			<label class="sr-only" for="exampleInputEmail3">Email address</label>
			<input type="email" class="form-control" id="exampleInputEmail3" placeholder="Email">
			</div>
			<div class="form-group">
			<label class="sr-only" for="exampleInputPassword3">Password</label>
			<input type="password" class="form-control" id="exampleInputPassword3" placeholder="Password">
			</div>
			<div class="checkbox">
			<label>
			<input type="checkbox"> Remember me
			</label>
			</div>
			<button type="submit" class="btn btn-default">Sign in</button>
			</form>
$
.00
<form class="form-inline">
			<div class="form-group">
			<label class="sr-only" for="exampleInputAmount">Amount (in dollars)</label>
			<div class="input-group">
			<div class="input-group-addon">$</div>
			<input type="text" class="form-control" id="exampleInputAmount" placeholder="Amount">
			<div class="input-group-addon">.00</div>
			</div>
			</div>
			<button type="submit" class="btn btn-primary">Transfer cash</button>
			</form>

Horizontal form

Use Bootstrap's predefined grid classes to align labels and groups of form controls in a horizontal layout by adding .form-horizontal to the form (which doesn't have to be a <form>). Doing so changes .form-groups to behave as grid rows, so no need for .row.

<form class="form-horizontal">
			<div class="form-group">
			<label for="inputEmail3" class="col-sm-2 control-label">Email</label>
			<div class="col-sm-10">
			<input type="email" class="form-control" id="inputEmail3" placeholder="Email">
			</div>
			</div>
			<div class="form-group">
			<label for="inputPassword3" class="col-sm-2 control-label">Password</label>
			<div class="col-sm-10">
			<input type="password" class="form-control" id="inputPassword3" placeholder="Password">
			</div>
			</div>
			<div class="form-group">
			<div class="col-sm-offset-2 col-sm-10">
			<div class="checkbox">
			<label>
			  <input type="checkbox"> Remember me
			</label>
			</div>
			</div>
			</div>
			<div class="form-group">
			<div class="col-sm-offset-2 col-sm-10">
			<button type="submit" class="btn btn-default">Sign in</button>
			</div>
			</div>
			</form>

Supported controls

Examples of standard form controls supported in an example form layout.

Inputs

Most common form control, text-based input fields. Includes support for all HTML5 types: text, password, datetime, datetime-local, date, month, time, week, number, email, url, search, tel, and color.

Type declaration required

Inputs will only be fully styled if their type is properly declared.

<input type="text" class="form-control" placeholder="Text input">

Input groups

To add integrated text or buttons before and/or after any text-based <input>, check out the input group component.

Textarea

Form control which supports multiple lines of text. Change rows attribute as necessary.

<textarea class="form-control" rows="3"></textarea>

Checkboxes and radios

Checkboxes are for selecting one or several options in a list, while radios are for selecting one option from many.

Disabled checkboxes and radios are supported, but to provide a "not-allowed" cursor on hover of the parent <label>, you'll need to add the .disabled class to the parent .radio, .radio-inline, .checkbox, or .checkbox-inline.

Default (stacked)


<div class="checkbox">
			<label>
			<input type="checkbox" value="">
			Option one is this and that&mdash;be sure to include why it's great
			</label>
			</div>
			<div class="checkbox disabled">
			<label>
			<input type="checkbox" value="" disabled>
			Option two is disabled
			</label>
			</div>

			<div class="radio">
			<label>
			<input type="radio" name="optionsRadios" id="optionsRadios1" value="option1" checked>
			Option one is this and that&mdash;be sure to include why it's great
			</label>
			</div>
			<div class="radio">
			<label>
			<input type="radio" name="optionsRadios" id="optionsRadios2" value="option2">
			Option two can be something else and selecting it will deselect option one
			</label>
			</div>
			<div class="radio disabled">
			<label>
			<input type="radio" name="optionsRadios" id="optionsRadios3" value="option3" disabled>
			Option three is disabled
			</label>
			</div>

Inline checkboxes and radios

Use the .checkbox-inline or .radio-inline classes on a series of checkboxes or radios for controls that appear on the same line.


<label class="checkbox-inline">
			<input type="checkbox" id="inlineCheckbox1" value="option1"> 1
			</label>
			<label class="checkbox-inline">
			<input type="checkbox" id="inlineCheckbox2" value="option2"> 2
			</label>
			<label class="checkbox-inline">
			<input type="checkbox" id="inlineCheckbox3" value="option3"> 3
			</label>

			<label class="radio-inline">
			<input type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1"> 1
			</label>
			<label class="radio-inline">
			<input type="radio" name="inlineRadioOptions" id="inlineRadio2" value="option2"> 2
			</label>
			<label class="radio-inline">
			<input type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3"> 3
			</label>

Checkboxes and radios without label text

Should you have no text within the <label>, the input is positioned as you'd expect. Currently only works on non-inline checkboxes and radios. Remember to still provide some form of label for assistive technologies (for instance, using aria-label).

<div class="checkbox">
			<label>
			<input type="checkbox" id="blankCheckbox" value="option1" aria-label="...">
			</label>
			</div>
			<div class="radio">
			<label>
			<input type="radio" name="blankRadio" id="blankRadio1" value="option1" aria-label="...">
			</label>
			</div>

Selects

Note that many native select menus—namely in Safari and Chrome—have rounded corners that cannot be modified via border-radius properties.

<select class="form-control">
			<option>1</option>
			<option>2</option>
			<option>3</option>
			<option>4</option>
			<option>5</option>
			</select>

For <select> controls with the multiple attribute, multiple options are shown by default.

<select multiple class="form-control">
			<option>1</option>
			<option>2</option>
			<option>3</option>
			<option>4</option>
			<option>5</option>
			</select>

Static control

When you need to place plain text next to a form label within a form, use the .form-control-static class on a <p>.

[email protected]

<form class="form-horizontal">
			<div class="form-group">
			<label class="col-sm-2 control-label">Email</label>
			<div class="col-sm-10">
			<p class="form-control-static">[email protected]</p>
			</div>
			</div>
			<div class="form-group">
			<label for="inputPassword" class="col-sm-2 control-label">Password</label>
			<div class="col-sm-10">
			<input type="password" class="form-control" id="inputPassword" placeholder="Password">
			</div>
			</div>
			</form>

[email protected]

<form class="form-inline">
			<div class="form-group">
			<label class="sr-only">Email</label>
			<p class="form-control-static">[email protected]</p>
			</div>
			<div class="form-group">
			<label for="inputPassword2" class="sr-only">Password</label>
			<input type="password" class="form-control" id="inputPassword2" placeholder="Password">
			</div>
			<button type="submit" class="btn btn-default">Confirm identity</button>
			</form>

Focus state

We remove the default outline styles on some form controls and apply a box-shadow in its place for :focus.

Demo :focus state

The above example input uses custom styles in our documentation to demonstrate the :focus state on a .form-control.

Disabled state

Add the disabled boolean attribute on an input to prevent user interactions. Disabled inputs appear lighter and add a not-allowed cursor.

<input class="form-control" id="disabledInput" type="text" placeholder="Disabled input here..." disabled>

Disabled fieldsets

Add the disabled attribute to a <fieldset> to disable all the controls within the <fieldset> at once.

Caveat about link functionality of <a>

By default, browsers will treat all native form controls (<input>, <select> and <button> elements) inside a <fieldset disabled> as disabled, preventing both keyboard and mouse interactions on them. However, if your form also includes <a ... class="btn btn-*"> elements, these will only be given a style of pointer-events: none. As noted in the section about disabled state for buttons (and specifically in the sub-section for anchor elements), this CSS property is not yet standardized and isn't fully supported in Opera 18 and below, or in Internet Explorer 11, and won't prevent keyboard users from being able to focus or activate these links. So to be safe, use custom JavaScript to disable such links.

Cross-browser compatibility

While Bootstrap will apply these styles in all browsers, Internet Explorer 11 and below don't fully support the disabled attribute on a <fieldset>. Use custom JavaScript to disable the fieldset in these browsers.

<form>
			<fieldset disabled>
			<div class="form-group">
			<label for="disabledTextInput">Disabled input</label>
			<input type="text" id="disabledTextInput" class="form-control" placeholder="Disabled input">
			</div>
			<div class="form-group">
			<label for="disabledSelect">Disabled select menu</label>
			<select id="disabledSelect" class="form-control">
			<option>Disabled select</option>
			</select>
			</div>
			<div class="checkbox">
			<label>
			<input type="checkbox"> Can't check this
			</label>
			</div>
			<button type="submit" class="btn btn-primary">Submit</button>
			</fieldset>
			</form>

Readonly state

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.

<input class="form-control" type="text" placeholder="Readonly input here…" readonly>

Help text

Block level help text for form controls.

Associating help text with form controls

Help text should be explicitly associated with the form control it relates to using the aria-describedby attribute. This will ensure that assistive technologies – such as screen readers – will announce this help text when the user focuses or enters the control.

A block of help text that breaks onto a new line and may extend beyond one line.
<label class="sr-only" for="inputHelpBlock">Input with help text</label>
			<input type="text" id="inputHelpBlock" class="form-control" aria-describedby="helpBlock">
			...
			<span id="helpBlock" class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</span>

Validation states

Bootstrap includes validation styles for error, warning, and success states on form controls. To use, add .has-warning, .has-error, or .has-success to the parent element. Any .control-label, .form-control, and .help-block within that element will receive the validation styles.

Conveying validation state to assistive technologies and colorblind users

Using these validation styles to denote the state of a form control only provides a visual, color-based indication, which will not be conveyed to users of assistive technologies - such as screen readers - or to colorblind users.

Ensure that an alternative indication of state is also provided. For instance, you can include a hint about state in the form control's <label> text itself (as is the case in the following code example), include a Glyphicon (with appropriate alternative text using the .sr-only class - see the Glyphicon examples), or by providing an additional help text block. Specifically for assistive technologies, invalid form controls can also be assigned an aria-invalid="true" attribute.

A block of help text that breaks onto a new line and may extend beyond one line.
<div class="form-group has-success">
			<label class="control-label" for="inputSuccess1">Input with success</label>
			<input type="text" class="form-control" id="inputSuccess1" aria-describedby="helpBlock2">
			<span id="helpBlock2" class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</span>
			</div>
			<div class="form-group has-warning">
			<label class="control-label" for="inputWarning1">Input with warning</label>
			<input type="text" class="form-control" id="inputWarning1">
			</div>
			<div class="form-group has-error">
			<label class="control-label" for="inputError1">Input with error</label>
			<input type="text" class="form-control" id="inputError1">
			</div>
			<div class="has-success">
			<div class="checkbox">
			<label>
			<input type="checkbox" id="checkboxSuccess" value="option1">
			Checkbox with success
			</label>
			</div>
			</div>
			<div class="has-warning">
			<div class="checkbox">
			<label>
			<input type="checkbox" id="checkboxWarning" value="option1">
			Checkbox with warning
			</label>
			</div>
			</div>
			<div class="has-error">
			<div class="checkbox">
			<label>
			<input type="checkbox" id="checkboxError" value="option1">
			Checkbox with error
			</label>
			</div>
			</div>

With optional icons

You can also add optional feedback icons with the addition of .has-feedback and the right icon.

Feedback icons only work with textual <input class="form-control"> elements.

Icons, labels, and input groups

Manual positioning of feedback icons is required for inputs without a label and for input groups with an add-on on the right. You are strongly encouraged to provide labels for all inputs for accessibility reasons. If you wish to prevent labels from being displayed, hide them with the .sr-only class. If you must do without labels, adjust the top value of the feedback icon. For input groups, adjust the right value to an appropriate pixel value depending on the width of your addon.

Conveying the icon's meaning to assistive technologies

To ensure that assistive technologies – such as screen readers – correctly convey the meaning of an icon, additional hidden text should be included with the .sr-only class and explicitly associated with the form control it relates to using aria-describedby. Alternatively, ensure that the meaning (for instance, the fact that there is a warning for a particular text entry field) is conveyed in some other form, such as changing the text of the actual <label> associated with the form control.

Although the following examples already mention the validation state of their respective form controls in the <label> text itself, the above technique (using .sr-only text and aria-describedby) has been included for illustrative purposes.

(success)
(warning)
(error)
@
(success)
<div class="form-group has-success has-feedback">
			<label class="control-label" for="inputSuccess2">Input with success</label>
			<input type="text" class="form-control" id="inputSuccess2" aria-describedby="inputSuccess2Status">
			<span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
			<span id="inputSuccess2Status" class="sr-only">(success)</span>
			</div>
			<div class="form-group has-warning has-feedback">
			<label class="control-label" for="inputWarning2">Input with warning</label>
			<input type="text" class="form-control" id="inputWarning2" aria-describedby="inputWarning2Status">
			<span class="glyphicon glyphicon-warning-sign form-control-feedback" aria-hidden="true"></span>
			<span id="inputWarning2Status" class="sr-only">(warning)</span>
			</div>
			<div class="form-group has-error has-feedback">
			<label class="control-label" for="inputError2">Input with error</label>
			<input type="text" class="form-control" id="inputError2" aria-describedby="inputError2Status">
			<span class="glyphicon glyphicon-remove form-control-feedback" aria-hidden="true"></span>
			<span id="inputError2Status" class="sr-only">(error)</span>
			</div>
			<div class="form-group has-success has-feedback">
			<label class="control-label" for="inputGroupSuccess1">Input group with success</label>
			<div class="input-group">
			<span class="input-group-addon">@</span>
			<input type="text" class="form-control" id="inputGroupSuccess1" aria-describedby="inputGroupSuccess1Status">
			</div>
			<span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
			<span id="inputGroupSuccess1Status" class="sr-only">(success)</span>
			</div>

Optional icons in horizontal and inline forms

(success)
@
(success)
<form class="form-horizontal">
			<div class="form-group has-success has-feedback">
			<label class="control-label col-sm-3" for="inputSuccess3">Input with success</label>
			<div class="col-sm-9">
			<input type="text" class="form-control" id="inputSuccess3" aria-describedby="inputSuccess3Status">
			<span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
			<span id="inputSuccess3Status" class="sr-only">(success)</span>
			</div>
			</div>
			<div class="form-group has-success has-feedback">
			<label class="control-label col-sm-3" for="inputGroupSuccess2">Input group with success</label>
			<div class="col-sm-9">
			<div class="input-group">
			<span class="input-group-addon">@</span>
			<input type="text" class="form-control" id="inputGroupSuccess2" aria-describedby="inputGroupSuccess2Status">
			</div>
			<span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
			<span id="inputGroupSuccess2Status" class="sr-only">(success)</span>
			</div>
			</div>
			</form>
(success)

@
(success)
<form class="form-inline">
			<div class="form-group has-success has-feedback">
			<label class="control-label" for="inputSuccess4">Input with success</label>
			<input type="text" class="form-control" id="inputSuccess4" aria-describedby="inputSuccess4Status">
			<span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
			<span id="inputSuccess4Status" class="sr-only">(success)</span>
			</div>
			</form>
			<form class="form-inline">
			<div class="form-group has-success has-feedback">
			<label class="control-label" for="inputGroupSuccess3">Input group with success</label>
			<div class="input-group">
			<span class="input-group-addon">@</span>
			<input type="text" class="form-control" id="inputGroupSuccess3" aria-describedby="inputGroupSuccess3Status">
			</div>
			<span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
			<span id="inputGroupSuccess3Status" class="sr-only">(success)</span>
			</div>
			</form>

Optional icons with hidden .sr-only labels

If you use the .sr-only class to hide a form control's <label> (rather than using other labelling options, such as the aria-label attribute), Bootstrap will automatically adjust the position of the icon once it's been added.

(success)
@
(success)
<div class="form-group has-success has-feedback">
			<label class="control-label sr-only" for="inputSuccess5">Hidden label</label>
			<input type="text" class="form-control" id="inputSuccess5" aria-describedby="inputSuccess5Status">
			<span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
			<span id="inputSuccess5Status" class="sr-only">(success)</span>
			</div>
			<div class="form-group has-success has-feedback">
			<label class="control-label sr-only" for="inputGroupSuccess4">Input group with success</label>
			<div class="input-group">
			<span class="input-group-addon">@</span>
			<input type="text" class="form-control" id="inputGroupSuccess4" aria-describedby="inputGroupSuccess4Status">
			</div>
			<span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
			<span id="inputGroupSuccess4Status" class="sr-only">(success)</span>
			</div>

Control sizing

Set heights using classes like .input-lg, and set widths using grid column classes like .col-lg-*.

Height sizing

Create taller or shorter form controls that match button sizes.

<input class="form-control input-lg" type="text" placeholder=".input-lg">
			<input class="form-control" type="text" placeholder="Default input">
			<input class="form-control input-sm" type="text" placeholder=".input-sm">

			<select class="form-control input-lg">...</select>
			<select class="form-control">...</select>
			<select class="form-control input-sm">...</select>

Horizontal form group sizes

Quickly size labels and form controls within .form-horizontal by adding .form-group-lg or .form-group-sm.

<form class="form-horizontal">
			<div class="form-group form-group-lg">
			<label class="col-sm-2 control-label" for="formGroupInputLarge">Large label</label>
			<div class="col-sm-10">
			<input class="form-control" type="text" id="formGroupInputLarge" placeholder="Large input">
			</div>
			</div>
			<div class="form-group form-group-sm">
			<label class="col-sm-2 control-label" for="formGroupInputSmall">Small label</label>
			<div class="col-sm-10">
			<input class="form-control" type="text" id="formGroupInputSmall" placeholder="Small input">
			</div>
			</div>
			</form>

Column sizing

Wrap inputs in grid columns, or any custom parent element, to easily enforce desired widths.

<div class="row">
			<div class="col-xs-2">
			<input type="text" class="form-control" placeholder=".col-xs-2">
			</div>
			<div class="col-xs-3">
			<input type="text" class="form-control" placeholder=".col-xs-3">
			</div>
			<div class="col-xs-4">
			<input type="text" class="form-control" placeholder=".col-xs-4">
			</div>
			</div>

Buttons

Button tags

Use the button classes on an <a>, <button>, or <input> element.

Link
<a class="btn btn-default" href="#" role="button">Link</a>
			<button class="btn btn-default" type="submit">Button</button>
			<input class="btn btn-default" type="button" value="Input">
			<input class="btn btn-default" type="submit" value="Submit">

Context-specific usage

While button classes can be used on <a> and <button> elements, only <button> elements are supported within our nav and navbar components.

Links acting as buttons

If the <a> elements are used to act as buttons – triggering in-page functionality, rather than navigating to another document or section within the current page – they should also be given an appropriate role="button".

Cross-browser rendering

As a best practice, we highly recommend using the <button> element whenever possible to ensure matching cross-browser rendering.

Among other things, there's a bug in Firefox <30 that prevents us from setting the line-height of <input>-based buttons, causing them to not exactly match the height of other buttons on Firefox.

Options

Use any of the available button classes to quickly create a styled button.

<!-- Standard button -->
			<button type="button" class="btn btn-default">Default</button>

			<!-- Provides extra visual weight and identifies the primary action in a set of buttons -->
			<button type="button" class="btn btn-primary">Primary</button>

			<!-- Indicates a successful or positive action -->
			<button type="button" class="btn btn-success">Success</button>

			<!-- Contextual button for informational alert messages -->
			<button type="button" class="btn btn-info">Info</button>

			<!-- Indicates caution should be taken with this action -->
			<button type="button" class="btn btn-warning">Warning</button>

			<!-- Indicates a dangerous or potentially negative action -->
			<button type="button" class="btn btn-danger">Danger</button>

			<!-- Deemphasize a button by making it look like a link while maintaining button behavior -->
			<button type="button" class="btn btn-link">Link</button>

Conveying meaning to assistive technologies

Using color to add meaning to a button only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (the visible text of the button), or is included through alternative means, such as additional text hidden with the .sr-only class.

Sizes

Fancy larger or smaller buttons? Add .btn-lg, .btn-sm, or .btn-xs for additional sizes.

<p>
			<button type="button" class="btn btn-primary btn-lg">Large button</button>
			<button type="button" class="btn btn-default btn-lg">Large button</button>
			</p>
			<p>
			<button type="button" class="btn btn-primary">Default button</button>
			<button type="button" class="btn btn-default">Default button</button>
			</p>
			<p>
			<button type="button" class="btn btn-primary btn-sm">Small button</button>
			<button type="button" class="btn btn-default btn-sm">Small button</button>
			</p>
			<p>
			<button type="button" class="btn btn-primary btn-xs">Extra small button</button>
			<button type="button" class="btn btn-default btn-xs">Extra small button</button>
			</p>

Create block level buttons—those that span the full width of a parent— by adding .btn-block.

<button type="button" class="btn btn-primary btn-lg btn-block">Block level button</button>
			<button type="button" class="btn btn-default btn-lg btn-block">Block level button</button>

Active state

Buttons will appear pressed (with a darker background, darker border, and inset shadow) when active. For <button> elements, this is done via :active. For <a> elements, it's done with .active. However, you may use .active on <button>s (and include the aria-pressed="true" attribute) should you need to replicate the active state programmatically.

Button element

No need to add :active as it's a pseudo-class, but if you need to force the same appearance, go ahead and add .active.

<button type="button" class="btn btn-primary btn-lg active">Primary button</button>
			<button type="button" class="btn btn-default btn-lg active">Button</button>

Anchor element

Add the .active class to <a> buttons.

Primary link Link

<a href="#" class="btn btn-primary btn-lg active" role="button">Primary link</a>
			<a href="#" class="btn btn-default btn-lg active" role="button">Link</a>

Disabled state

Make buttons look unclickable by fading them back with opacity.

Button element

Add the disabled attribute to <button> buttons.

<button type="button" class="btn btn-lg btn-primary" disabled="disabled">Primary button</button>
			<button type="button" class="btn btn-default btn-lg" disabled="disabled">Button</button>

Cross-browser compatibility

If you add the disabled attribute to a <button>, Internet Explorer 9 and below will render text gray with a nasty text-shadow that we cannot fix.

Anchor element

Add the .disabled class to <a> buttons.

Primary link Link

<a href="#" class="btn btn-primary btn-lg disabled" role="button">Primary link</a>
			<a href="#" class="btn btn-default btn-lg disabled" role="button">Link</a>

We use .disabled as a utility class here, similar to the common .active class, so no prefix is required.

Link functionality caveat

This class uses pointer-events: none to try to disable the link functionality of <a>s, but that CSS property is not yet standardized and isn't fully supported in Opera 18 and below, or in Internet Explorer 11. In addition, even in browsers that do support pointer-events: none, keyboard navigation remains unaffected, meaning that sighted keyboard users and users of assistive technologies will still be able to activate these links. So to be safe, use custom JavaScript to disable such links.

Dropdowns

Toggleable, contextual menu for displaying lists of links. Made interactive with the dropdown JavaScript plugin.

Wrap the dropdown's trigger and the dropdown menu within .dropdown, or another element that declares position: relative;. Then add the menu's HTML.

<div class="dropdown">
			<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
			Dropdown
			<span class="caret"></span>
			</button>
			<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
			<li><a href="#">Action</a></li>
			<li><a href="#">Another action</a></li>
			<li><a href="#">Something else here</a></li>
			<li role="separator" class="divider"></li>
			<li><a href="#">Separated link</a></li>
			</ul>
			</div>

Dropdown menus can be changed to expand upwards (instead of downwards) by adding .dropup to the parent.

<div class="dropup">
			<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
			Dropup
			<span class="caret"></span>
			</button>
			<ul class="dropdown-menu" aria-labelledby="dropdownMenu2">
			<li><a href="#">Action</a></li>
			<li><a href="#">Another action</a></li>
			<li><a href="#">Something else here</a></li>
			<li role="separator" class="divider"></li>
			<li><a href="#">Separated link</a></li>
			</ul>
			</div>

By default, a dropdown menu is automatically positioned 100% from the top and along the left side of its parent. Add .dropdown-menu-right to a .dropdown-menu to right align the dropdown menu.

May require additional positioning

Dropdowns are automatically positioned via CSS within the normal flow of the document. This means dropdowns may be cropped by parents with certain overflow properties or appear out of bounds of the viewport. Address these issues on your own as they arise.

Deprecated .pull-right alignment

As of v3.1.0, we've deprecated .pull-right on dropdown menus. To right-align a menu, use .dropdown-menu-right. Right-aligned nav components in the navbar use a mixin version of this class to automatically align the menu. To override it, use .dropdown-menu-left.

<ul class="dropdown-menu dropdown-menu-right" aria-labelledby="dLabel">
			...
			</ul>

Add a header to label sections of actions in any dropdown menu.

<ul class="dropdown-menu" aria-labelledby="dropdownMenu3">
			...
			<li class="dropdown-header">Dropdown header</li>
			...
			</ul>

Add a divider to separate series of links in a dropdown menu.

<ul class="dropdown-menu" aria-labelledby="dropdownMenuDivider">
			...
			<li role="separator" class="divider"></li>
			...
			</ul>

Add .disabled to a <li> in the dropdown to disable the link.

<ul class="dropdown-menu" aria-labelledby="dropdownMenu4">
			<li><a href="#">Regular link</a></li>
			<li class="disabled"><a href="#">Disabled link</a></li>
			<li><a href="#">Another link</a></li>
			</ul>

Button groups

Group a series of buttons together on a single line with the button group. Add on optional JavaScript radio and checkbox style behavior with our buttons plugin.

Tooltips & popovers in button groups require special setting

When using tooltips or popovers on elements within a .btn-group, you'll have to specify the option container: 'body' to avoid unwanted side effects (such as the element growing wider and/or losing its rounded corners when the tooltip or popover is triggered).

Ensure correct role and provide a label

In order for assistive technologies – such as screen readers – to convey that a series of buttons is grouped, an appropriate role attribute needs to be provided. For button groups, this would be role="group", while toolbars should have a role="toolbar".

One exception are groups which only contain a single control (for instance the justified button groups with <button> elements) or a dropdown.

In addition, groups and toolbars should be given an explicit label, as most assistive technologies will otherwise not announce them, despite the presence of the correct role attribute. In the examples provided here, we use aria-label, but alternatives such as aria-labelledby can also be used.

Basic example

Wrap a series of buttons with .btn in .btn-group.

<div class="btn-group" role="group" aria-label="...">
			<button type="button" class="btn btn-default">Left</button>
			<button type="button" class="btn btn-default">Middle</button>
			<button type="button" class="btn btn-default">Right</button>
			</div>

Button toolbar

Combine sets of <div class="btn-group"> into a <div class="btn-toolbar"> for more complex components.

<div class="btn-toolbar" role="toolbar" aria-label="...">
			<div class="btn-group" role="group" aria-label="...">...</div>
			<div class="btn-group" role="group" aria-label="...">...</div>
			<div class="btn-group" role="group" aria-label="...">...</div>
			</div>

Sizing

Instead of applying button sizing classes to every button in a group, just add .btn-group-* to each .btn-group, including when nesting multiple groups.




<div class="btn-group btn-group-lg" role="group" aria-label="...">...</div>
			<div class="btn-group" role="group" aria-label="...">...</div>
			<div class="btn-group btn-group-sm" role="group" aria-label="...">...</div>
			<div class="btn-group btn-group-xs" role="group" aria-label="...">...</div>

Nesting

Place a .btn-group within another .btn-group when you want dropdown menus mixed with a series of buttons.

<div class="btn-group" role="group" aria-label="...">
			<button type="button" class="btn btn-default">1</button>
			<button type="button" class="btn btn-default">2</button>

			<div class="btn-group" role="group">
			<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
			Dropdown
			<span class="caret"></span>
			</button>
			<ul class="dropdown-menu">
			<li><a href="#">Dropdown link</a></li>
			<li><a href="#">Dropdown link</a></li>
			</ul>
			</div>
			</div>

Vertical variation

Make a set of buttons appear vertically stacked rather than horizontally. Split button dropdowns are not supported here.

<div class="btn-group-vertical" role="group" aria-label="...">
			...
			</div>

Justified button groups

Make a group of buttons stretch at equal sizes to span the entire width of its parent. Also works with button dropdowns within the button group.

Handling borders

Due to the specific HTML and CSS used to justify buttons (namely display: table-cell), the borders between them are doubled. In regular button groups, margin-left: -1px is used to stack the borders instead of removing them. However, margin doesn't work with display: table-cell. As a result, depending on your customizations to Bootstrap, you may wish to remove or re-color the borders.

IE8 and borders

Internet Explorer 8 doesn't render borders on buttons in a justified button group, whether it's on <a> or <button> elements. To get around that, wrap each button in another .btn-group.

See #12476 for more information.

With <a> elements

Just wrap a series of .btns in .btn-group.btn-group-justified.

<div class="btn-group btn-group-justified" role="group" aria-label="...">
			...
			</div>

Links acting as buttons

If the <a> elements are used to act as buttons – triggering in-page functionality, rather than navigating to another document or section within the current page – they should also be given an appropriate role="button".

With <button> elements

To use justified button groups with <button> elements, you must wrap each button in a button group. Most browsers don't properly apply our CSS for justification to <button> elements, but since we support button dropdowns, we can work around that.

<div class="btn-group btn-group-justified" role="group" aria-label="...">
			<div class="btn-group" role="group">
			<button type="button" class="btn btn-default">Left</button>
			</div>
			<div class="btn-group" role="group">
			<button type="button" class="btn btn-default">Middle</button>
			</div>
			<div class="btn-group" role="group">
			<button type="button" class="btn btn-default">Right</button>
			</div>
			</div>

Button dropdowns

Use any button to trigger a dropdown menu by placing it within a .btn-group and providing the proper menu markup.

Plugin dependency

Button dropdowns require the dropdown plugin to be included in your version of Bootstrap.

Single button dropdowns

Turn a button into a dropdown toggle with some basic markup changes.

<!-- Single button -->
			<div class="btn-group">
			<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
			Action <span class="caret"></span>
			</button>
			<ul class="dropdown-menu">
			<li><a href="#">Action</a></li>
			<li><a href="#">Another action</a></li>
			<li><a href="#">Something else here</a></li>
			<li role="separator" class="divider"></li>
			<li><a href="#">Separated link</a></li>
			</ul>
			</div>

Split button dropdowns

Similarly, create split button dropdowns with the same markup changes, only with a separate button.

<!-- Split button -->
			<div class="btn-group">
			<button type="button" class="btn btn-danger">Action</button>
			<button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
			<span class="caret"></span>
			<span class="sr-only">Toggle Dropdown</span>
			</button>
			<ul class="dropdown-menu">
			<li><a href="#">Action</a></li>
			<li><a href="#">Another action</a></li>
			<li><a href="#">Something else here</a></li>
			<li role="separator" class="divider"></li>
			<li><a href="#">Separated link</a></li>
			</ul>
			</div>

Sizing

Button dropdowns work with buttons of all sizes.

<!-- Large button group -->
			<div class="btn-group">
			<button class="btn btn-default btn-lg dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
			Large button <span class="caret"></span>
			</button>
			<ul class="dropdown-menu">
			...
			</ul>
			</div>

			<!-- Small button group -->
			<div class="btn-group">
			<button class="btn btn-default btn-sm dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
			Small button <span class="caret"></span>
			</button>
			<ul class="dropdown-menu">
			...
			</ul>
			</div>

			<!-- Extra small button group -->
			<div class="btn-group">
			<button class="btn btn-default btn-xs dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
			Extra small button <span class="caret"></span>
			</button>
			<ul class="dropdown-menu">
			...
			</ul>
			</div>

Dropup variation

Trigger dropdown menus above elements by adding .dropup to the parent.

<div class="btn-group dropup">
			<button type="button" class="btn btn-default">Dropup</button>
			<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
			<span class="caret"></span>
			<span class="sr-only">Toggle Dropdown</span>
			</button>
			<ul class="dropdown-menu">
			<!-- Dropdown menu links -->
			</ul>
			</div>

Input groups

Extend form controls by adding text or buttons before, after, or on both sides of any text-based <input>. Use .input-group with an .input-group-addon or .input-group-btn to prepend or append elements to a single .form-control.

Textual <input>s only

Avoid using <select> elements here as they cannot be fully styled in WebKit browsers.

Avoid using <textarea> elements here as their rows attribute will not be respected in some cases.

Tooltips & popovers in input groups require special setting

When using tooltips or popovers on elements within an .input-group, you'll have to specify the option container: 'body' to avoid unwanted side effects (such as the element growing wider and/or losing its rounded corners when the tooltip or popover is triggered).

Don't mix with other components

Do not mix form groups or grid column classes directly with input groups. Instead, nest the input group inside of the form group or grid-related element.

Always add labels

Screen readers will have trouble with your forms if you don't include a label for every input. For these input groups, ensure that any additional label or functionality is conveyed to assistive technologies.

The exact technique to be used (visible <label> elements, <label> elements hidden using the .sr-only class, or use of the aria-label, aria-labelledby, aria-describedby, title or placeholder attribute) and what additional information will need to be conveyed will vary depending on the exact type of interface widget you're implementing. The examples in this section provide a few suggested, case-specific approaches.

Basic example

Place one add-on or button on either side of an input. You may also place one on both sides of an input.

We do not support multiple add-ons (.input-group-addon or .input-group-btn) on a single side.

We do not support multiple form-controls in a single input group.

@

@example.com

$ .00

https://example.com/users/
<div class="input-group">
			<span class="input-group-addon" id="basic-addon1">@</span>
			<input type="text" class="form-control" placeholder="Username" aria-describedby="basic-addon1">
			</div>

			<div class="input-group">
			<input type="text" class="form-control" placeholder="Recipient's username" aria-describedby="basic-addon2">
			<span class="input-group-addon" id="basic-addon2">@example.com</span>
			</div>

			<div class="input-group">
			<span class="input-group-addon">$</span>
			<input type="text" class="form-control" aria-label="Amount (to the nearest dollar)">
			<span class="input-group-addon">.00</span>
			</div>

			<label for="basic-url">Your vanity URL</label>
			<div class="input-group">
			<span class="input-group-addon" id="basic-addon3">https://example.com/users/</span>
			<input type="text" class="form-control" id="basic-url" aria-describedby="basic-addon3">
			</div>

Sizing

Add the relative form sizing classes to the .input-group itself and contents within will automatically resize—no need for repeating the form control size classes on each element.

@

@

@
<div class="input-group input-group-lg">
			<span class="input-group-addon" id="sizing-addon1">@</span>
			<input type="text" class="form-control" placeholder="Username" aria-describedby="sizing-addon1">
			</div>

			<div class="input-group">
			<span class="input-group-addon" id="sizing-addon2">@</span>
			<input type="text" class="form-control" placeholder="Username" aria-describedby="sizing-addon2">
			</div>

			<div class="input-group input-group-sm">
			<span class="input-group-addon" id="sizing-addon3">@</span>
			<input type="text" class="form-control" placeholder="Username" aria-describedby="sizing-addon3">
			</div>

Checkboxes and radio addons

Place any checkbox or radio option within an input group's addon instead of text.

<div class="row">
			<div class="col-lg-6">
			<div class="input-group">
			<span class="input-group-addon">
			<input type="checkbox" aria-label="...">
			</span>
			<input type="text" class="form-control" aria-label="...">
			</div><!-- /input-group -->
			</div><!-- /.col-lg-6 -->
			<div class="col-lg-6">
			<div class="input-group">
			<span class="input-group-addon">
			<input type="radio" aria-label="...">
			</span>
			<input type="text" class="form-control" aria-label="...">
			</div><!-- /input-group -->
			</div><!-- /.col-lg-6 -->
			</div><!-- /.row -->

Button addons

Buttons in input groups are a bit different and require one extra level of nesting. Instead of .input-group-addon, you'll need to use .input-group-btn to wrap the buttons. This is required due to default browser styles that cannot be overridden.

<div class="row">
			<div class="col-lg-6">
			<div class="input-group">
			<span class="input-group-btn">
			<button class="btn btn-default" type="button">Go!</button>
			</span>
			<input type="text" class="form-control" placeholder="Search for...">
			</div><!-- /input-group -->
			</div><!-- /.col-lg-6 -->
			<div class="col-lg-6">
			<div class="input-group">
			<input type="text" class="form-control" placeholder="Search for...">
			<span class="input-group-btn">
			<button class="btn btn-default" type="button">Go!</button>
			</span>
			</div><!-- /input-group -->
			</div><!-- /.col-lg-6 -->
			</div><!-- /.row -->

Buttons with dropdowns

<div class="row">
			<div class="col-lg-6">
			<div class="input-group">
			<div class="input-group-btn">
			<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Action <span class="caret"></span></button>
			<ul class="dropdown-menu">
			<li><a href="#">Action</a></li>
			<li><a href="#">Another action</a></li>
			<li><a href="#">Something else here</a></li>
			<li role="separator" class="divider"></li>
			<li><a href="#">Separated link</a></li>
			</ul>
			</div><!-- /btn-group -->
			<input type="text" class="form-control" aria-label="...">
			</div><!-- /input-group -->
			</div><!-- /.col-lg-6 -->
			<div class="col-lg-6">
			<div class="input-group">
			<input type="text" class="form-control" aria-label="...">
			<div class="input-group-btn">
			<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Action <span class="caret"></span></button>
			<ul class="dropdown-menu dropdown-menu-right">
			<li><a href="#">Action</a></li>
			<li><a href="#">Another action</a></li>
			<li><a href="#">Something else here</a></li>
			<li role="separator" class="divider"></li>
			<li><a href="#">Separated link</a></li>
			</ul>
			</div><!-- /btn-group -->
			</div><!-- /input-group -->
			</div><!-- /.col-lg-6 -->
			</div><!-- /.row -->

Segmented buttons

<div class="input-group">
			<div class="input-group-btn">
			<!-- Button and dropdown menu -->
			</div>
			<input type="text" class="form-control" aria-label="...">
			</div>

			<div class="input-group">
			<input type="text" class="form-control" aria-label="...">
			<div class="input-group-btn">
			<!-- Button and dropdown menu -->
			</div>
			</div>

Multiple buttons

While you can only have one add-on per side, you can have multiple buttons inside a single .input-group-btn.

<div class="input-group">
			<div class="input-group-btn">
			<!-- Buttons -->
			</div>
			<input type="text" class="form-control" aria-label="...">
			</div>

			<div class="input-group">
			<input type="text" class="form-control" aria-label="...">
			<div class="input-group-btn">
			<!-- Buttons -->
			</div>
			</div>