Input

A specialized field for HTML input elements


  • Display

    Inline Flex

  • Selectors

    .input
  • Source

    GitHub ↗

  • Features

    TonesPriorities

<input type='text' class='input ~neutral !normal w-auto' placeholder='Hello world'>

Overview

Inputs are a specialized type of field for use with most <input> elements. For more information on why this is useful, check out the field documentation.

Currently, the .input selector is simply an alias for the .field selector. It’s possible that input-specific features will be added in the future.

Considerations

Multiple (adjacent) inputs — You can build adjacent inputs by removing the left or right border from the fields and setting their x-margin to zero. Beware that using adjacent fields can result in a poor user experience on mobile.

Variants

Inputs have full tone, priority, and disabling support. Priorities are communicated through elevation.

Low Priority
Example code
<input class="input ~neutral !low mb-4 mr-4 w-auto" placeholder="This is an input" type="text">

<input class="input ~positive !low mb-4 mr-4 w-auto" placeholder="This is an input" type="text">

<input class="input ~warning !low mb-4 mr-4 w-auto" placeholder="This is an input" type="text">

<input class="input ~critical !low mb-4 mr-4 w-auto" placeholder="This is an input" type="text">

<input class="input ~info !low mb-4 mr-4 w-auto" placeholder="This is an input" type="text">

<input class="input ~urge !low mb-4 mr-4 w-auto" placeholder="This is an input" type="text">
Normal Priority
Example code
<input class="input ~neutral !normal mb-4 mr-4 w-auto" placeholder="This is an input" type="text">

<input class="input ~positive !normal mb-4 mr-4 w-auto" placeholder="This is an input" type="text">

<input class="input ~warning !normal mb-4 mr-4 w-auto" placeholder="This is an input" type="text">

<input class="input ~critical !normal mb-4 mr-4 w-auto" placeholder="This is an input" type="text">

<input class="input ~info !normal mb-4 mr-4 w-auto" placeholder="This is an input" type="text">

<input class="input ~urge !normal mb-4 mr-4 w-auto" placeholder="This is an input" type="text">
High Priority
Example code
<input class="input ~neutral !high mb-4 mr-4 w-auto" placeholder="This is an input" type="text">

<input class="input ~positive !high mb-4 mr-4 w-auto" placeholder="This is an input" type="text">

<input class="input ~warning !high mb-4 mr-4 w-auto" placeholder="This is an input" type="text">

<input class="input ~critical !high mb-4 mr-4 w-auto" placeholder="This is an input" type="text">

<input class="input ~info !high mb-4 mr-4 w-auto" placeholder="This is an input" type="text">

<input class="input ~urge !high mb-4 mr-4 w-auto" placeholder="This is an input" type="text">
Disabling
Example code
<input class="input ~neutral" value="This is a disabled input" type="text" disabled>

Accessibility

Use Aria roles and labels. When building forms, it’s easy to rely on visual guidelines to show relationships between elements. Unfortunately, this doesn’t help those interacting with your site using a screenreader or other assistive technologies. For this reason, it’s important to use ARIA labels and roles wherever possible.

Don't use color to communicate. Instead, use color to support information you communicate through text. When this isn't possible, be sure to use a title attribute.

Be mindful of contrast. What looks good to you may not be readable for others. Text contrast is a good thing!

Support all navigation modes. Some people will interact with your interface using assitive technologies and/or a keyboard. Build your interface with these different modes in mind (for example, by setting the `tab-index` attribute on all interactive elements that aren't interactive by default).

Examples

Your name

Just your first name is fine, too.

Example code
<div>
  <p class="label">Your name</p>
  <input class="my-1 field" type="text" placeholder="Miles McCain">
  <p class="support">Just your first name is fine, too.</p>
</div>

Your name

That's an email, not a name!

Example code
<div>
  <p class="label">Your name</p>
  <input class="field my-1 ~critical" type="text" placeholder="Miles McCain" value="[email protected]">
  <p class="support ~critical">That's an email, not a name!</p>
</div>

Customization

Name Type Default Description
--color-light color sets default border color
--field-shadow-transition-speed time 75ms sets the speed of the hover and focus transition
--fallback-box-shadow box shadow sets the base box shadow
--field-disabled-opacity opacity 0.8 sets the opacity of disabled fields
--field-hover-box-shadow box shadow 0 0 1px 1px var(--color-light) sets additional box shadow on hover
--field-focus-box-shadow box shadow 0 0 0 2px var(--color-light) sets additional box shadow on focus

You can also customize this element by simply overriding any of its CSS attributes, listed here. Contextual variable defaults (e.g., --color-content) and global variables (e.g., --family-primary) are defined here.