Form controls in a drawn setting

Four ideas from the element catalogue, built. Each canvas draws a scene and puts real form controls in it: labels pulled away from their fields, a date input on a wall calendar, a file input as the slot of a letter box, and a fieldset under frost. Tap a call-out, tap a day, post some files, and lock the panel. The text under each canvas is read from the form.

Exploded form diagram

One form. Each <label> is drawn as a call-out, away from its field, and the canvas draws the line between them. The fields are drawn sheared, as layers. Tap a call-out: the browser focuses its field. Type in a field, then press Send with a field empty.

The labels and fields are separate drawable elements, joined only by for. The canvas decides where each one is drawn. Focus, the checkbox toggle and the validation message come from the browser. The two lines of small text under a call-out are read from the field's type, required and validity.

Show the code
  1. Mark every label and every field drawable. The form itself isn't drawn.
  2. Draw each label, its field under a shear, and a line between them.
  3. Report what the browser did. No code here focuses anything.
  4. Styles.

Wall calendar around a date input

An <input type="date"> and an <input type="month"> are drawn on the top sheet of a calendar. Tap a day in the grid, type a date, or use the two buttons. When the month changes, the old sheet is torn off and falls, with a picture of the inputs as they were.

The two inputs hold the state. The grid, the month name and the red ring are canvas drawing made from their values. The falling sheet shows the old date because captureElementImage() took a picture of each input at the last paint, before the value changed.

Show the code
  1. Two inputs, two buttons and one element over the grid.
  2. Draw one sheet from a month, with the live inputs or with pictures of them.
  3. Tear off the old sheet when the month changes.
  4. Typing, the buttons and a tap on the grid all write the inputs.
  5. Styles.

File input on a drawn letter box

The slot in the brass plate is an <input type="file" multiple>. Tap it to choose files, or drop files on it. Each file drops through the slot onto the mat: a picture as a print, any other file as an envelope. Tap one on the mat to take it out of input.files.

The input's button and its count of files are the browser's own picture of the element. The page makes one <button drawable> for each file in input.files, and draws it where it has fallen, so each one can be tapped or reached with the Tab key there.

Show the code
  1. One file input in the canvas.
  2. Make one element for each chosen file.
  3. Draw the input on the plate, and each file on its way from the slot to the mat.
  4. A tap on a file writes a shorter list to input.files.
  5. Styles.

Disabled panel in one step

Tick "Lock this panel". That sets disabled on the <fieldset>, which disables every control in it except the ones in its legend. The canvas grows frost over the panel. Touch the frost: the patch clears and freezes again, and the control under it doesn't respond.

The browser greys the controls, takes them out of the Tab order and leaves them out of the form data. The page adds the frost: the fieldset drawn a second time through ctx.filter = 'blur()', a haze and crystal lines, clipped to a shape that grows from the edges.

Show the code
  1. One drawable fieldset, with the lock in its legend.
  2. The lock sets one attribute.
  3. Draw the fieldset, then the frost over it.
  4. A press on a disabled control still reaches the canvas.
  5. Styles.

How it works

Each canvas holds its controls as descendants marked drawable. A paint handler draws the scene with 2D calls and each control with drawElementImage(), which also moves the control's hit region to where it was drawn. The page uses 2D canvases only. A demo starts when its section comes near the screen.

Show the code
  1. Scale a 380 unit design space to the canvas.
  2. The paint loop, the draw helpers and the fallback to plain HTML.
  3. Each demo starts when its section comes near the screen.

Live checks

The checks wait for a tap. Each one builds its own small canvas in a corner of the window, or runs in a hidden copy of this page, and none of them touches the demos above.

Findings

Measured in headless Chromium 157 on 2026-11-21, with a mouse, a keyboard and emulated touch at 412 px wide. Nothing on this page has been run on a phone.