--- title: Elements seoTitle: Form elements summary: Inputs, selects, textareas, checkboxes, radios and switches, with their sizes, states and the input group add-ons. docs-libs: [nouislider] description: Styled inputs, selects, checkboxes and radios, with states, sizes and layout options. order: 1 related: [/ui/forms/validation, /ui/forms/helpers, /ui/forms/fieldset, /ui/plugins/date-picker, /ui/plugins/advanced-select] css-vars: control sass-vars: input --- import Example from '@components/Example.astro'; import Icon from '@ui/Icon.astro' ## Classic inputs Add the `form-control` class to a text input to style it. Give every input a label, and use the placeholder for an example value rather than as the label. ```html ``` All variants of the input control are available in the examples below:
## Form control rounded Use the `form-control-rounded` class if you prefer form controls with rounded corners.
## Form control flush You can remove borders from your form control by adding the `form-control-flush` class. ## Input with icon Put an [icon](/ui/components/icon) inside an input to hint at what goes in it, or a spinner to show that the field is busy.
## Separated inputs Include an additional element in your input section, such as a [button](/ui/components/button) which can be used to submit the information entered in the input control.
## Textarea and select Use a multi-line text input control to enable users to enter longer pieces of text. The control will automatically adjust to the length of the text entered. Add one of the available selects - either a dropdown or a multiple choice select - to let users choose from a predefined set of options.
Select
Select multiple
## Input size Inputs come in three sizes: small, default and large.
The sizes come from one scale of custom properties on `:root`, shared by buttons and form controls and named as in Bootstrap 6: `--tblr-btn-input-padding-y`, `--tblr-btn-input-padding-x`, `--tblr-btn-input-font-size`, `--tblr-btn-input-line-height`, `--tblr-btn-input-border-radius` and `--tblr-btn-input-min-height`, plus a `--tblr-btn-input-sm-*`, `--tblr-btn-input-lg-*` and `--tblr-btn-input-xl-*` set for each size. Override them on `:root` to change every control at once. ```css :root { --tblr-btn-input-padding-y: 0.75rem; --tblr-btn-input-border-radius: 0; } ``` ## Datalists Use the `datalist` element to add an autocomplete feature to your input control. The list of available options will display once a user starts to type and will make it quicker to complete form sections.
## Toggle switches Use toggle switches for the elements of your form which require choosing between two opposing states.
Toggle switches
Disabled switches
Single switch
## Radios Use radio buttons for the parts of your form which require users to choose one option from a set of two or more mutually exclusive options.
Radios
Inline Radios
## Checkboxes Use checkboxes if you want to allow users to select more than one option from a set of predefined options or to turn an option on or off. Checks, radios and switches share their state colors through `--tblr-control-checked-bg`, `--tblr-control-checked-border-color`, `--tblr-control-disabled-bg` and `--tblr-control-disabled-opacity` on `:root`. Each control also has its own tokens: `--tblr-form-check-*` on `.form-check-input` and `--tblr-form-switch-*` on `.form-switch`.
Checkboxes
Inline Checkboxes
## Range input Add a [range slider](/ui/plugins/range-slider) to make it possible for users to set a value or range, such as a price range or a time frame. The track and the thumb read `--tblr-range-*` custom properties on `.form-range`: `--tblr-range-track-height`, `--tblr-range-track-bg`, `--tblr-range-thumb-width`, `--tblr-range-thumb-bg`, `--tblr-range-thumb-border` and the rest of the `track-*` and `thumb-*` set.
## Input group Create a group of input controls and place add-ons on either side of an input. The add-on reads `--tblr-input-group-addon-*` custom properties on `.input-group` (`padding-y`, `padding-x`, `font-size`, `line-height`, `color`, `bg`, `border-color`, `border-radius`). `.input-group-sm` and `.input-group-lg` only change these tokens and pass them on to the controls in the group.
@
.tabler.io
https:// .tabler.io
## Input with checkboxes or radios Add checkboxes or radio buttons on either side of your input control.
## Input with prepended or appended text Add text to your input control, either before or after the text which is to be entered by a user.
https://tabler.io/users/
.tabler.io
## Input with appended link Include a link in your input control to add a clickable element within the control.
## Input with appended kbd Include a `` in your input control to add a shortcut hint to the control.
ctrl + K
## Input with appended icon links Add an icon link which you want to display at the end of your input control to visually represent actions which a user can take.
## Horizontal form Put the label and the field in one `row` to place them side by side. The label takes `col-form-label` instead of `form-label`, which keeps it aligned with the field rather than sitting above it. Add `required` to the label to append a red asterisk.
## Form footer Wrap the buttons that close a form in `form-footer`. It only adds the top margin that separates them from the last field, so the spacing is the same in every form.
## Accessibility - Every field needs a `label` with a `for` that matches the field id. A placeholder is not a label - it disappears as soon as the user types. - When the design has no room for a visible label, keep the `label` and hide it with `visually-hidden` rather than dropping it. - Tie help text and errors to the field with `aria-describedby`, so they are read together with it. See [form helpers](/ui/forms/helpers) and [validation states](/ui/forms/validation). - Mark a required field with the `required` attribute, not only with an asterisk in the label. - Group related checkboxes or radios in a `fieldset` with a `legend`. The legend is the only thing that names the group. See [fieldsets](/ui/forms/fieldset). - Keep `input` types honest - `email`, `tel`, `url` and `number` change the on-screen keyboard on phones and let the browser validate for you. - Do not disable a field to make it read-only. `disabled` removes it from the tab order and from the submitted data; `readonly` keeps both.