Menu

Menu

On this page

On this page

Input

A component for displaying form input elements.

npm install @vrembem/input
Copied!
SCSS
@use "@vrembem/input";
Copied!

Options

Input uses design token CSS variables in a reference and fallback pattern. Variables are referenced in the component's styles but are not directly defined; instead, they are provided with sensible fallbacks.

VariableFallback
--vb-input-accent
Copied!
--vb-input-font-size
Copied!
--vb-input-line-height
Copied!
--vb-input-padding
Copied!
--vb-input-border-radius
Copied!
--vb-input-border-width
Copied!
--vb-input-background
Copied!
--vb-input-foreground
Copied!
--vb-input-border-color
Copied!
--vb-input-box-shadow
Copied!
--vb-input-background-hover
Copied!
--vb-input-foreground-hover
Copied!
--vb-input-border-color-hover
Copied!
--vb-input-box-shadow-hover
Copied!
--vb-input-background-focus
Copied!
--vb-input-foreground-focus
Copied!
--vb-input-box-shadow-focus
Copied!
none
Copied!
--vb-input-foreground-placeholder
Copied!
--vb-input-background-readonly
Copied!
--vb-input-background-disabled
Copied!
--vb-input-opacity-disabled
Copied!

Basic usage

The most basic implementation of the input component consists of the input class applied to an <input> element.

HTML
<input class="input" type="text" placeholder="Example input..." />
Copied!

Disabled

Adding the boolean disabled attribute to the input will provide visual indication that the input is not available for use.

HTML
<input class="input" type="text" disabled />
Copied!

Readonly

Adding the boolean readonly attribute to the input will provide visual indication that the user should not be able to edit the value of the input.

HTML
<input class="input" type="text" readonly />
Copied!

Textarea

Apply the input class to a <textarea> element to apply styles with textarea specific properties. use the rows attribute to adjust the initial height.

HTML
<textarea class="input" rows="3">...</textarea>
Copied!

Invalid

Adding the is-invalid class or aria-invalid="true" attribute to the input will provide visual indication that the form-control value is invalid. Invalid state is also triggered by the native :user-invalid state.

HTML
<input class="input is-invalid" type="text" value="Invalid input..." />
<textarea class="input is-invalid" rows="3">...</textarea>
Copied!