Data inputs and controls contain a huge array of styled default form elements, as well as all of the variations necessary for common application use cases. This document is huge because there are so many!
Please also note that there are many accessibility rules and concerns and that we’ve tried to document and mark them up here to make this as easy as possible.
Text input
The first and most varied data input here is the text input. This includes regular text inputs, as well as all of the semantic variations (email, password, date etc.).
Create a text input by using the <input> element and adding type="text" and class .hc-input. This creates a basic, default text input with all states handled. The type that you use will dictate many of the styles and interactions.
A text input will expand to fill the size of its container by default. You can always set its width directly using utility classes, like .w-1/2, but we recommend adjusting the width of the container and not directly overriding the input’s width.
Text input sizes
Small and large text inputs are available for specific contexts. Append the classes .hc-input--sm or .hc-input--lg to make them smaller or larger.
Validation and disabled states
Alter the validation state of the input by appending classes .hc-input--success, .hc-input-warning, or .hc-input--danger.
You can also disable an input by adding the disabled attribute, or appending the class .hc-input--disabled. For accessibility purposes, disabled inputs should always have the attribute.
Date and time inputs
Date and time text inputs are semantic variations of the regular text input, but use type="date" and type="time" instead, respectively.
Create these the same way as a regular text input but modifying those input types.
Browsers have their own method of handling the date and time pickers, as well as what icon is overlayed to the right of the input. Honeycomb does not override these defaults.
Text input labels
Text inputs can receive up to 4 label “slots” when wrapped with a <label> element that has class .hc-form-control.
The top left slot is the primary input label. The top right slot handles required notices. The bottom left is for microcopy or explanatory text, and the bottom right is reserved for the input character count, if used.
Within the label, create a <span> with class .hc-label for each label “row,” one above the input and one below if used. Inside each of these spans should be additional <span> elements with classes .hc-label-text, .hc-label-required, .hc-label-microcropy, and .hc-label-count.
Icons over text inputs
While there are a few built-in specialty text inputs that automatically overlay semantic icons, you can embed any icon to the left and/or right of the text input as well.
Wrap the text input with a label that has class .hc-input-overlays and place icons before and/or after the input inside of this wrapper. The first one will be positioned to the left of the input and the second one will be positioned to the right.
Specialty text inputs
Certain use cases can call for special text inputs, like a search box or if you’d like to add a leading icon to the input. We provide a few of these out of the box.
Search input
To create a search-style input, use type="search" and append the class .hc-input--search to it.
Note that when it’s in a table control bar or the navigation bar, a search input will take on a fully rounded border in the pill style.
Other icons available
You can append the classes .hc-input--phone, .hc-input--user, .hc-input--email, and .hc-user--password to add leading icons the same way search is handled.
These inputs should have a type of tel, email, username, and password, respectively, to keep their semantic use cases and leverage browser defaults.
Placeholder to label effect
For special inputs you can send the input’s placeholder text to its label position when the user focuses on the input. This is a cool way to handle login forms or other special forms where space might be a concern or where coolness is a factor.
Add the class .hc-input--placeholder-label to the text input, and then wrap it and a <label> immediately following it inside of a wrapper element with class .hc-form-control.
This works with the special text inputs above that include leading icons as well.
Accessibility note
Still include the placeholder attribute on these inputs even though the opacity is 0. It’s a fallback and will still be picked up by screen readers.
Select
Select is used to pick a value from a list of options. Honeycomb overrides the default browser display of the select input and instead uses a custom chevron to normalize this cross-browser.
Create a default select by using the <select> element with class .hc-select.
The placeholder for a select should be the first option in the list of options, with attributes selected and disabled.
Select sizes
Small and large selects are available for specific contexts. Append the classes .hc-select--sm or .hc-select--lg to make them smaller or larger.
Validation and disabled states
Alter the validation state of the select by appending classes .hc-select--success, .hc-select-warning, or .hc-select--danger.
You can also disable a select just like inputs: add the disabled attribute, or append the class .hc-input--disabled. For accessibility purposes, disabled selects should always have the attribute.
Multiple options
Add the multiple attribute to a <select> element to allow users to select more than one option. The markup for this is the same, and the browser will handle multi-select natively.
Size attribute
Use the size attribute on a normal select element to specify the number of visible options in the list. It looks similar to a multi-select but it’s still a single select element, just displaying more than 1 value.
Textarea
Textarea is a multi-line text field input that can be used to receive longer chuncks of text from the user. Use these for comment boxes, message boxes, or where the user needs to enter a description.
For a basic textarea, add the class .hc-textarea. If you’d like to increase the height, we recommend changing the height of the wrapping element as opposed to setting the rows attribute. You can also add a height utility class to this textarea alternatively.
Textarea sizes
Small and large textareas are available for specific contexts. Append the classes .hc-textarea--sm or .hc-textarea--lg to make them smaller or larger.
Validation and disabled states
Alter the validation state of the textarea by appending classes .hc-textarea--success, .hc-textarea--warning, or .hc-textarea--danger.
You can also disable a select just like inputs: add the disabled attribute, or append the class .hc-textarea--disabled. For accessibility purposes, disabled selects should always have the attribute.
Checkbox
Checkboxes are used to select or deselect one or more values in a list. If the user must be limited to selecting only one value, use a radio instead.
Create a basic checkbox element by using the <input type="checkbox"> with class .hc-checkbox. Pre-select it by adding the attribute checked="checked".
Checkbox labels
To add a label to the checkbox, wrap the input with a <label> element with class .hc-form-control, then add an .hc-label span next to the checkbox itself. Inside of that, create a span with class .hc-label-text.
Sizes
Adjust the size of the checkbox to be small or large with classes .hc-checkbox--sm and .hc-checkbox--lg, respectively.
Validation and disabled states
Alter the validation state of the checkbox by appending classes .hc-checkbox--success, .hc-checkbox--warning, or .hc-checkbox--danger.
You can also disable a checkbox just like the other inputs: add the disabled attribute, or append the class .hc-checkbox--disabled. For accessibility purposes, disabled checkboxes should always have the attribute.
Helper text
Add helper or assistance text below the checkbox label by adding a <span> with class .hc-label-microcopy right below the .hc-label-text span.
Checkbox list group
Stack checkboxes vertically in a list group by using a <ul> element with class .hc-checkbox-group. Set the width directly on this wrapper element or on a parent above it.
Indeterminate state
If you programmatically set a checkbox to be indeterminate, the check will change to a dash as expexcted.
Note that this is not an HTML attribute and must be set via Javascript, such as input.indeterminate = true;.
Radio Button
Similar to a checkbox, the radio button (or just radio) element can be used to receive just one selected option from the user.
Create a basic radio element by using the <input type="radio"> with class .hc-radio. Pre-select it by adding the attribute checked="checked". You’ll notice that most of the attributes and class names are identical to checkboxes, just that checkox is replaced with radio.
Radio buttons part of the same group should have the same unique name value.
Radio labels
To add a label to the radio, wrap the input with a <label> element with class .hc-form-control, then add an .hc-label span next to the radio itself. Inside of that, create a span with class .hc-label-text.
Sizes
Adjust the size of the radio to be small or large with classes .hc-radio--sm and .hc-radio--lg, respectively.
Validation and disabled states
Alter the validation state of the radio by appending classes .hc-radio--success, .hc-radio--warning, or .hc-radio--danger.
You can also disable a radio just like the other inputs: add the disabled attribute, or append the class .hc-radio--disabled. For accessibility purposes, disabled radios should always have the attribute.
Helper text
Add helper or assistance text below the radio label by adding a <span> with class .hc-label-microcopy right below the .hc-label-text span.
Radio list group
Stack radio buttons vertically in a list group by using a <ul> element with class .hc-radio-group. Set the width directly on this wrapper element or on a parent above it.
Toggle
Toggles let the user switch between a binary state of true or false, similar to a 2-choice radio group. The difference is typically that the toggle will immediately save the change/state, whereas a radio requires an active form submission.
Create a basic toggle with just a single checkbox with class .hc-toggle. Interactions are handled automatically, but it’s up to you to manage the state and any requests.
Toggles overload the checkbox element as there is no native HTML element for this yet. Radios are recommended for accessibility reasons, but if you choose to use toggles please ensure you’re adhering to all accessibility attributes documented here.
Toggle labels
Toggles should have a label for both comprehension and accessibility reasons. Wrap the checkbox in the same manner as labels documented above.
Toggle sizes
Adjust the size of the toggle to be small or large with classes .hc-toggle--sm and .hc-toggle--lg, respectively.
Validation and disabled states
Alter the validation state of the toggle by appending classes .hc-toggle--success, .hc-toggle--warning, or .hc-toggle--danger.
You can also disable a toggle just like the other inputs: add the disabled attribute, or append the class .hc-toggle--disabled. For accessibility purposes, disabled toggles should always have the attribute.
File input
File input is the input field for uploading files. Often you’ll use a drag-and-drop interface for uploading, but for one-off file uploads this input is standard.
Create a file input by adding the class .hc-file-input to an <input> element with type="file". The input will fill whatever container it’s in, though you can add a max-width class to it directly or adjust the width of the wrapping container.
File input with labels
Add labels to the top and bottom of the file input the same way you would with the text input, select, and textarea.
Validation and disabled states
Alter the validation state of the file input by appending classes .hc-file-input--success, .hc-file-input--warning, or .hc-file-input--danger.
You can also disable a file input just like the other inputs: add the disabled attribute, or append the class .hc-file-input--disabled. For accessibility purposes, disabled file inputs should always have the attribute.