One-time code

Material Design 3 text field web components: lit-material-text-field (single-line) and lit-material-textarea (multi-line) — filled + outlined, validation states.

  • 11.0 KB gzipped
  • @lit-material/text-field 1.8.0
  • Renders on the server

Example

Install

npm install @lit-material/text-field @lit-material/tokens
import "@lit-material/text-field/one-time-code.js";

Link @lit-material/tokens/css/index.css once per page for the colour, type and shape tokens. Install guide

API

<lit-material-one-time-code>

A one-time code: the digits from a sign-in or confirmation mail, an authenticator app or a text message. One native input underneath a row of boxes, so typing, paste, deleting, the phone's code suggestion (autocomplete="one-time-code") and screen readers all work as in a plain field. Spaces and dashes in a pasted code are dropped.

Properties

PropertyAttributeTypeDefaultDescription
valuevaluestring""The code typed so far.
lengthlengthnumber6How many characters the code has.
alphanumericalphanumericbooleanfalseLetters as well as digits (upper-cased as typed). Digits only by default.
groupSizegroup-sizenumber0A small gap after this many boxes, e.g. 3 for "123 456". 0 for none.
labellabelstring""Visible label above the boxes.
supportingTextsupporting-textstring""
errorTexterror-textstring""
errorerrorbooleanfalse
disableddisabledbooleanfalse
requiredrequiredbooleanfalse
namenamestring""

Events

EventDescription
completeWhen the last character is entered; detail is { value }. Submit or verify here.
inputBubbles while the code is typed.

CSS parts

PartDescription
cellsThe row of boxes.
cellEach box.
supportingThe supporting or error text.

Source on GitHub npm