Date, time and colour pickers drawn by a canvas

<input type="date">, type="time" and type="color" open pickers that the browser draws. A page can't style them, and unlike a customisable select they have no part a canvas can go in. I tested two things. First, a replacement picker in which every day, hour and swatch is a real button drawn by a canvas, on the same input element. Second, what happens to the built-in controls and pickers when the input itself is drawn in a canvas.

Three pickers made of buttons in a canvas

Tap a field. The time field opens a clock: choose an hour, the hours fold into the centre and the minutes come out. Drag round the face for single minutes. The date field opens a month: the arrows, a sideways swipe or Page Up and Page Down slide to another month. The colour field shows the colours of its <datalist> in rings. On a keyboard, type in the field as usual, or press Alt and Arrow Down to move into the picker.

Show the code pickers made of buttons in a canvas
  1. Ordinary inputs with a picker attribute. min and max on the date input disable the days outside them.
  2. Load the library.
  3. Inside the library: open the popover in place of the browser's picker.
  4. The clock. place() says where each button goes. The buttons of the ring that is not in use get a target at the centre with no opacity, so they move there and fade.
  5. The calendar. from() gives the incoming buttons a starting point off to one side.
  6. The swatches.
  7. The shared part: each frame, move every button a little towards its target and draw it. drawElementImage() puts the button's hit box where it was drawn, so taps, hover and the focus ring follow.
  8. Writing the value back fires input and change on the input.

The built-in controls drawn in a canvas

This form is one drawable child of a canvas, drawn rotated. Every control in it is the browser's own. Type in the date, drag the range, tick the box, and open the pickers. The table below lists what was seen in the test browser.

-8°

Show the code a form of built-in controls as a drawable child
  1. The form is a drawable child of the canvas.
  2. One rotated drawElementImage(). Nothing is done for any control.
ControlDrawn rotatedUsed where it is drawnIts picker
date, time, datetime-local, month, weekYes, with the segment that has focus highlightedA click on a segment focuses that segment, and typing changes itNot observed (see the findings)
numberYes, with its spin buttonsTyping worksNone
colorYesA click opens the chooserOpens upright next to the bounding box of the drawn swatch. Not drawn by the canvas
range with a datalistYes, with tick marksA click on the track sets the value at that point along the rotated trackNone
fileYesThe button takes the clickThe operating system's dialog
checkbox, radioYesYesNone
progress, meterYesNot interactiveNone

Findings

More to try with inputs

Live checks

These run on test inputs in a panel at the bottom of the window, not on the fields above. They wait for a tap because they open test pickers on top of the page.