Veylo Docs

HomeDocsForms

Forms

Native form controls are restyled with no classes. They keep their native behaviour, so they submit, validate and work with assistive technology as usual.

Text fields

<div class="row"><label for="n">Name</label><input id="n" type="text" class="grow"></div>
<div class="row"><label for="pw">Password</label><input id="pw" data-veylo-mask class="grow"></div>
<div class="row"><label for="s">Channel</label><select id="s"><option>stable</option></select></div>
<div class="row"><label for="t">Notes</label><textarea id="t" rows="2" class="grow"></textarea></div>

Supported: text, email, url, tel, number, date and the other date and time types, search, file, textarea, select (single, and size for a list box), and fieldset. Fields are sunken, use the field colour, and show the dotted focus ring.

data-veylo-mask (needs veylo.js) shows * for each typed character, like a Windows 98 password box. The real value is in input.dataset.value. It does not use type=password, so browsers will not offer to save it.

Rows and labels

Wrap a label and its control in .row for one aligned line. A label that comes first and has no input inside gets a 7rem minimum width, so a stack of rows lines up in a column. Add grow to the control to fill the line. Rows wrap on narrow screens.

Group box

Options
<fieldset class="veylo-group">
  <legend>Options</legend>
  ...
</fieldset>

fieldset.veylo-group is an etched Win98 group box with a legend.

Checkboxes and radios

Checkboxes are square, radios are true circles (the only round element in Veylo). Set input.indeterminate = true for the mixed state. For a select-all box, give it data-veylo-all="name" and give the others name="name". Shift+click ticks a range of checkboxes.

<input type="checkbox" data-veylo-all="files" aria-label="Select all">
<input type="checkbox" name="files"> <input type="checkbox" name="files">

Switch, range, progress

See Buttons for the switch and Feedback for progress and meter.

Input group

https://
<div class="veylo-ig"><span>https://</span><input type="text"><button class="primary">Go</button></div>

.veylo-ig joins a text addon, an input and a button into one control.

<div class="veylo-search"><input type="search" placeholder="Search..."><button>Go</button></div>

Press / anywhere on the page (outside a text field) to focus the first input[type=search], or any input with data-veylo-search.

Colour picker

<div class="veylo-color" data-value="#6b45d6"></div>
<script>
  document.querySelector('.veylo-color').addEventListener('change', function (e) {
    console.log(e.detail.value);   // "#6b45d6"
  });
</script>

A swatch that opens a picker: a saturation square, a hue strip, a New and Current swatch, RGB and hex fields, and OK and Cancel. Click outside or press Esc to close. The square and the strip take the arrow keys (Shift for steps of 10). change fires with detail.value as a hex string.

Validation

Enter a valid address.
<div class="row"><label class="req" for="em">Email</label><input id="em" type="email" class="invalid"></div>
<span class="help err">Enter a valid address.</span>
ClassEffect
reqOn a label: adds a red asterisk
invalidOn a field: red border and background tint
helpSmall helper text under a field; add err for error colour

Caret styles

The text cursor can be a block, bar or underscore, like a terminal. Set it for the whole page with data-caret on .veylo (block, bar, underscore or auto), with veylo.setCaret('bar'), or add <select data-veylo-caret> for a picker. For one field use caret-block, caret-bar, caret-under, caret-auto, and caret-acc or caret-text for the colour. The default is a block. Browsers without caret-shape support show their normal caret.

.blink on an element appends a blinking block (mono blink gives a command-prompt look).