Whakerexa > Forms > Inputs

Inputs

All form and interactive element rules are included in wexa.css. Buttons, inputs, selects, textareas, checkboxes, range sliders and progress bars are styled by default and adapt to light and dark mode.

Buttons

A plain <button> renders as a primary action button. The disabled attribute visually reduces the button and removes interactivity. Wrap in .contrast to force the high-contrast rendering.

<button>a button</button>
<button disabled>disabled</button>
<div class="contrast">
    <button>a button</button>
    <button disabled>disabled</button>
</div>

An <input> that carries role="button" is given the same room as the one that carries type="button": a command carries no outer margin of its own. What acts on the form — submit and reset — is the one set apart from the fields above it.

<input type="button" value="an input button">
<input type="submit" value="a submit">
<input type="reset" value="a reset">

Variables

Interactive element colors are controlled by the following variables:

Variable Role
--buttons-bg-color Background color of primary buttons
--buttons-bg-color-hover Background color of buttons on hover
--buttons-fg-color Text color of buttons
--inputs-bg-color Background color of text inputs, select and textarea
--progress-bg-color Track color of progress bar and range slider
--progress-fg-color Fill color of the progress bar
--border-width Border thickness for inputs and the other commands
--border-radius Corner radius of the commands and the fields; a fieldset takes the frame's

Forms

Use <form> with <label> elements that reference their control via for/id. Wrap a group of related fields in <fieldset> with a <legend>. Every field — input, select, textarea — fills the available width automatically, so that a form reads as one column. An action takes the width of its label, and is set apart from the fields it follows.

Registration form with <fieldset>
<form method="get" action="#">
    <fieldset>
        <legend>Form legend</legend>
        <label for="field">Label:</label>
        <input name="field" type="text" id="field" />
        <button type="submit">Submit</button>
        <button type="reset">Reset</button>
    </fieldset>
</form>

Without a <fieldset>, fields and buttons sit flush in the flow. Labels and inputs remain block-level and stack vertically.

<form>
    <label for="price">Add funds:</label>
    <input id="price" type="text" placeholder="e.g. $10"/>
    <button type="submit">Pay</button>
</form>

Fields joined in a row

A <fieldset class="field-group"> lays what it holds in a row, joined: the fields share the room, the action takes the width of its label, and only the two ends of the row are rounded. The row places what it holds, so nothing inside it takes a margin of its own.

<fieldset class="field-group">
    <input type="text" placeholder="Your name" aria-label="Your name"/>
    <button type="submit">Send</button>
</fieldset>

Search

An <input type="search"> renders as a pill-shaped field with an embedded magnifying-glass icon. The field expands on focus to give more room for typing.

<form role="search">
    <label for="q">Search:</label>
    <input type="search" id="q" name="q" placeholder="Search…"/>
</form>

Validation states

Set aria-invalid="true" on an input to show an error icon. Set aria-invalid="false" to show a success icon. The icon appears inside the input field on the right side, and the border of the field takes the same color — --error-color or --success-color. A select and a textarea take the border too.

<input type="text" aria-invalid="false" value="correct"/>

<input type="text" aria-invalid="true" value="wrong"/>

Range slider

An <input type="range"> renders a full-width slider. The track uses --progress-bg-color and the thumb uses --buttons-bg-color. The thumb enlarges on hover.

<label for="volume">Volume:</label>
<input type="range" id="volume" min="0" max="100" value="60"/>

File input

An <input type="file"> renders a styled file-selector button followed by the selected filename. The button inherits the primary button colors.

<label for="avatar">Profile picture:</label>
<input type="file" id="avatar" accept="image/*"/>