nercone.devaboutlinkscontactsitemap
aboutlinkssitemap82ffc6419

Forms

Button, text field, dropdown, slider, and segmented control. Native form elements are styled without classes.

Button

Applies to <button>, <input type="button">, <input type="submit">, and <input type="reset">. Add the button class to other elements, such as <a>.

Variants

button-primary is for the main action of a form or popup. The status variants use the status colors of the theme.

Links and inputs

Back to HomeNext: Tables

Disabled

Use the disabled attribute, or aria-disabled="true" on elements that do not have it.

Error (a)

Customization

Change the padding with --button-padding (default 8px 16px) and the colors with --color-button-*. Each variant sets --color-button-foreground, -background, and -border from its own colors, such as --color-button-error-*. On hover, the background is mixed with --button-hover-background-mix of --color-foreground (default 10%), and the border with --button-hover-border-mix of --color-foreground-alt (default 0%). The status variants take both from the theme (--button-status-hover-background-mix and --button-status-hover-border-mix): the UD themes set them to 0% and 100%, so that the JIS safety color stays as it is and the border shows the hover. The mix is done on the button, so it follows colors overridden on an ancestor.

<button type="button">Cancel</button>
<button class="button-primary" type="submit">Save</button>
<a class="button button-error" href="/delete">Delete</a>

Text field

Applies to <textarea> and to <input> whose type is not set or is text, search, email, url, tel, password, number, date, time, datetime-local, month, or week. Add the textfield class to other elements.

States

The border turns to --color-error-normal with aria-invalid="true", or when the value fails validation after the user has changed it (:user-invalid), as the second field does after you edit it. A read-only field has no background.

Customization

Change the padding with --textfield-padding (default 8px 12px) and the colors with --color-textfield-*. The border on hover is --color-textfield-hover-border; text fields, dropdowns, and swatches have this variable.

<label for="email">Email</label>
<input id="email" type="email" placeholder="you@example.com">

Dropdown

Applies to <select>. Add the dropdown class to other elements. Invalid and disabled states are the same as the text field.

List

With multiple, or a size greater than 1, the options are drawn as a list. The list uses appearance: base-select, and shows as many rows as size (default 4); browsers that do not support it for lists show their native list.

Change the padding with --dropdown-padding (default 8px 12px), the padding of a list with --dropdown-list-padding (one length, default 4px), the padding of its rows with --dropdown-option-padding-block (default 4px) and --dropdown-option-padding-inline (default 8px), and the colors with --color-dropdown-*.

<select>
    <option>One</option>
    <option>Two</option>
</select>

Slider

Applies to <input type="range">. Add the slider class to other elements. slider.js fills the track up to the value by setting --slider-value (from 0 to 1). Without JavaScript, the track is drawn without the fill, except in Firefox, which draws it by itself.

States

Customization

Change the size with --slider-thickness (default 4px) and --slider-thumb-size (default 16px), and the colors with --color-slider-*.

<input type="range" min="0" max="100" value="30">
Note

slider.js follows user input, form resets, and changes of the value, min, and max attributes. Setting the value property from a script changes none of them, so call window.nercone.get('slider').update(element) afterwards.

Segmented control

A set of options where one is chosen. Put a radio button and a <span> in each <label>. The radio button stays focusable and readable by assistive technology, and the <span> is drawn. It needs no script.

Change the padding of each option with --segmented-control-padding (default 4px 12px) and the colors with --color-segmented-control-*. The options wrap onto more lines when they do not fit.

<div class="segmented-control" role="radiogroup" aria-label="View">
    <label><input type="radio" name="view" value="list" checked><span>List</span></label>
    <label><input type="radio" name="view" value="grid"><span>Grid</span></label>
</div>

Example

Contact

This form is not sent anywhere.