No description
This repository has been archived on 2026-04-29. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
  • TypeScript 81.3%
  • HTML 18.7%
Find a file
2025-12-22 06:46:49 +01:00
src Reformat project 2025-12-22 06:46:49 +01:00
.editorconfig Add EditorConfig 2025-12-22 06:43:38 +01:00
.gitignore Initial commit 2023-06-29 18:21:09 +02:00
.prettierignore Update prettier config 2025-12-22 06:45:57 +01:00
.prettierrc Reformat project 2025-12-22 06:46:49 +01:00
index.html Reformat project 2025-12-22 06:46:49 +01:00
mise.toml Add mise 2025-12-22 06:44:10 +01:00
package.json Reformat project 2025-12-22 06:46:49 +01:00
pnpm-lock.yaml Switch to pnpm 2025-12-22 06:45:00 +01:00
README.md Reformat project 2025-12-22 06:46:49 +01:00
screenshot.png Add README.md 2023-06-29 19:45:06 +02:00
tsconfig.json Reformat project 2025-12-22 06:46:49 +01:00

Segmented Input

This is a segmented input web component, written using Lit. It can be used, for instance, as input field for multi-factor authentication codes.

Screenshot

Features

  • Once you enter a digit, the next input field is focused and awaits your input.
  • When hitting the backspace key in an empty input field, the previous input field will be focused.
  • When pasting a value, it will be spread over all available input fields.
  • After all input fields are filled, a complete event containing the entered value is triggered.
  • The number of digits is customizable.
  • Can be used just like any regular form component.

Usage

With JavaScript

<segmented-input id="segmented-input"></segmented-input>

<script>
	const segmentedInput = document.getElementById('segmented-input');

	segmentedInput.addEventListener('complete', function (event) {
		console.log('Entered value: ' + event.detail);
	});
</script>

Within a HTML form

<form action="/check" method="post">
	<segmented-input name="code"></segmented-input>
	<button type="submit">Submit</button>
	<button type="reset">Reset</button>
</form>

Attributes

digits (default: 6)

The number of digits, the segmented input should contain.

<segmented-input digits="8"></segmented-input>

letters (default: false)

Control wether the segmented input should accept letters or not.

<segmented-input letters></segmented-input>