<style include="cr-shared-style">
:host {
--passcode-input-active-color: var(--color-sys-primary-container);
--passcode-input-background-color: var(--color-textfield-filled-background);
--passcode-input-background-color-focused: var(--color-sys-state-hover);
--passcode-input-color: var(--cr-primary-text-color);
--passcode-input-color-disabled: var(--color-sys-state-disabled);
--passcode-input-focus-color: var(--color-sys-primary);
--passcode-input-border-radius: 12px;
}
@keyframes blink {
from {
background-color: var(--passcode-input-focus-color);
}
to {
background-color: var(--passcode-input-focus-color);
}
50% {
background-color: transparent;
}
}
#container {
height: 48px;
position: relative;
text-align: unset;
}
.char {
color: var(--passcode-input-color);
margin: auto;
}
.char-box {
background-color: var(--passcode-input-background-color);
border-radius: var(--passcode-input-border-radius);
font-family: inherit;
font-size: 20px;
height: 40px;
line-height: 40px;
margin: 4px;
position: relative;
text-align: center;
transition: background-color 120ms ease-out;
vertical-align: middle;
width: 40px;
}
.char-box-container {
display: flex;
margin-inline-start: 14px;
position: absolute;
}
.char-box-focus {
background-color: transparent;
border-radius: var(--passcode-input-border-radius);
display: block;
inset: 0;
pointer-events: none;
position: absolute;
transition: background-color 120ms ease-in;
}
.cursor-filled::after {
animation: 1s blink step-end infinite;
background-color: var(--passcode-input-focus-color);
content: '';
height: 20px;
margin-inline-start: 2px;
position: absolute;
top: 10px;
width: 2px;
}
.cursor-empty::before {
animation: 1s blink step-end infinite;
background-color: var(--passcode-input-focus-color);
content: '';
height: 20px;
margin-inline-start: -1px;
position: absolute;
top: 10px;
width: 2px;
}
.cursor-start::before {
animation: 1s blink step-end infinite;
background-color: var(--passcode-input-focus-color);
content: '';
height: 20px;
margin-inline-start: -4px;
position: absolute;
top: 10px;
width: 2px;
}
.disabled {
color: var(--passcode-input-color-disabled);
}
.char-box.focused:not(.active) > .char-box-focus {
background-color: var(--passcode-input-background-color-focused);
transition: background-color 120ms ease-in;
}
.active {
background-color: var(--passcode-input-active-color);
}
.hidden-input {
font-family: monospace;
font-size: 20px;
letter-spacing: 36px;
opacity: 0;
padding: 11px;
position: absolute;
z-index: 100;
}
</style>
<div id='container'>
<input
aria-label="[[ariaLabel]]"
autocomplete="off"
class="hidden-input"
disabled="[[disabled]]"
id="inputElement"
spellcheck="false"
type="text"
>
<div class="char-box-container" aria-hidden="true">
<template is="dom-repeat" items="[[charDisplayBoxes]]" as="charBox">
<div class="char-box" id="char-box-[[index]]">
<div class="char-box-focus">
<p class="char" id="char-[[index]]"></p>
</div>
</div>
</template>
</div>
</div>