Skip to Content
Which part for what

Forms

InlineField, the form fields, NumberField, Slider and PropertyList.

InlineField

InlineField is text edited where it is shown.

VariantUse
titleA title, 20/28. multiline wraps it
textA property value, 28px
monoAn ID or a path

At rest it reads as text. On hover it has a bg-3 fill, and on focus it shows its edge and the focus ring. Enter commits, Escape reverts, and leaving the field commits. Do not use a raw <input> styled flat.

Title, text, mono and in a property list
Open the example ↗

Form fields

TextField, TextArea, Select, Switch and SchemaForm are 30px fields, with the label above in 12px text-2.

  • A Switch applies at once.
  • A Checkbox is part of a form, with a mixed state for select-all.
  • A RadioGroup picks one of a few visible options.
  • A Select is for long or changing sets, such as hosts or scopes. It is a button with aria-haspopup and a menu of radio items.
Default, help, error and disabled
Open the example ↗
Default, with a disabled option
Open the example ↗
SwitchA switch applies at once.
Open the example ↗

SchemaForm builds a form from a JSON Schema. See Fields.

NumberField

NumberField is 30px like the other fields. variant="inline" is 28px, for a PropertyList or a table cell.

  • It takes sums: 12*4, 100-15%, +5 from the value, and 1.5h with units.
  • The arrow keys step. Shift steps by ten, and Alt by a tenth.
  • Drag the label, or the field at rest with a mouse, to scrub.
  • A click places the caret, and Tab selects the value.
  • steppers sit stacked at the end on a desktop, and as − and + around the value on a phone.
  • The unit is unit, after the number, never in the label.
  • Input it cannot read keeps the old value and says why.

The arithmetic is evaluateExpression in src/lib/expression.ts, a parser with no eval.

Plain, with a unit, with steppers, with units it convertsDrag a label sideways to scrub (Shift ten steps, Alt a tenth), or use the arrow keys. The duration field takes 1.5h, 90m or 1h 30m.
Open the example ↗
Simple expressionsTyped sums are worked out on Enter or blur. A leading operator continues from the value, and input it cannot read keeps the old value and says why.
Open the example ↗
Inline, in a property list and a tableText at rest, bg-3 on hover, the edge on focus: the row keeps its height. Drag the value sideways with a mouse to scrub; click to type.
Open the example ↗
Inline numbers in a property listThe inline variant reads as a value, keeps the 28px row and lines up with the text values.
Open the example ↗
Form fields in a property listBoxed 30px fields with steppers outweigh the values around them, push the rows apart and break the value edge.
Open the example ↗

Slider

Slider and RangeSlider set a bounded value roughly.

  • A 28px row, a 4px track and a 14px thumb, with the value at the right of the label.
  • ticks and marks name the steps.
  • field adds a field for the exact number.
  • On a phone the hit area is 44px and the thumb 22px.

They are not for exact numbers over a large range.

One value, formattedThe value sits at the right of the label. Arrow keys move a step, Shift or Page Up and Down ten, Home and End to the ends.
Open the example ↗
Stepped, with ticks and labelsA few named steps: ticks at every step and a label under the ones that matter.
Open the example ↗
With a field for the exact valueDrag for a rough value, type in the field for an exact one (it takes sums: 512*2).
Open the example ↗
A bounded value with its readoutA slider for a value where roughly right is right; the value at the label's right, a field when it must be exact.
Open the example ↗
A slider for an exact numberA port from 1 to 65535 on a track, with no readout: a pixel is hundreds of ports, and nothing says which one is set.
Open the example ↗

PropertyList

PropertyList shows label and value pairs.

  • The label column is 120px, or labelWidth="auto", in 12px text-3.
  • Values are text-1.
  • Rows are 28px, so an InlineField or a Select keeps the row height.
  • An empty value is an em dash, never "None".
Fixed and sized-to-content labels
Open the example ↗
TextField in the gallery ↗
Edit on GitHub

Last updated on

On this page