Keypad
A phone-style numeric keypad that types an amount, fills PIN dots or drives another field, with a slot for a biometric key.
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
display | KeypadDisplay | amount | What shows above the keys: amount, pin dots, or none. |
value | string | — | The text typed: digits, and with an amount one decimal point. Kept to what the keys could have typed. |
length | number | 4 | How many digits a PIN has (display="pin"). |
decimals | number | 2 | Digits allowed after the decimal point of an amount; 0 removes the decimal key. |
max-length | number | 12 | The most characters an amount takes, the decimal point included. |
currency | string | — | ISO 4217 code of the currency the amount is shown in (USD, EUR); empty shows a plain number. |
for | string | — | The id of a field, in the same document or shadow root, that the keypad types into. |
name | string | — | Form field name: the form receives value. |
required | boolean | false | Asks for a value: an empty keypad is invalid. |
disabled | boolean | false | Turns the keys off; as for a disabled form control, the value is not submitted. |
label | string | — | The accessible name of the keypad. Inside a c2-form-field, the field's label names it. |
Slots
| Name | Description |
|---|---|
start | The bottom left key when there is no decimal key: a biometric button on a passcode screen. |
Events
| Name | Type | Description |
|---|---|---|
input | Event | Fired when a key changes the value. Read value. |
change | Event | Fired with input after each key that changes the value. Not fired for programmatic changes. |
complete | CustomEvent<{ value: string }> | With display="pin", fired when the last digit of the code is typed. |
CSS parts
Shadow DOM styling hooks used with ::part(name). Prefer CSS custom properties when they cover the change.
| Name | Description |
|---|---|
display | The amount or the dots above the keys. |
dot | One dot of a PIN. |
keys | The grid of keys. |
key | Every key. |
delete | The Delete key. |
CSS custom properties
Grouped by semantic target and state from --c2-<component>__<target>__<state>--<property>. Click a group to collapse it; click a name to copy it.
| Name | Type | Default | Description |
|---|---|---|---|
--c2-keypad--width | pixel | 280px | Width of the keypad; the keys share it in three columns. |
--c2-keypad__keys--gap | pixel | 8px | Space between the keys. |
--c2-keypad__key--height | pixel | 64px | |
--c2-keypad__key--background | background | #f4f4f5 | |
--c2-keypad__key--color | color | #18181b | |
--c2-keypad__key--border | border | none | |
--c2-keypad__key--border-radius | border-radius | 14px | |
--c2-keypad__key--font-size | font-size | 24px | |
--c2-keypad__key--font-weight | font-weight | 500 | |
--c2-keypad__key__hover--background | background | #e4e4e7 | |
--c2-keypad__key__active--background | background | #d4d4d8 | While a key is pressed. |
--c2-keypad__key__focus--outline | outline | 2px solid rgba(2, 101, 220, 0.4) | |
--c2-keypad__display--gap | pixel | 24px | Space between the display and the keys. |
--c2-keypad__display--color | color | #18181b | |
--c2-keypad__display--font-size | font-size | 40px | |
--c2-keypad__display--font-weight | font-weight | 600 | |
--c2-keypad__display__empty--color | color | #71717a | The zero an empty amount shows. |
--c2-keypad__display__error--color | color | #dc2626 | While an enclosing c2-form-field shows an error. |
--c2-keypad__dot--size | pixel | 14px | |
--c2-keypad__dot--gap | pixel | 16px | |
--c2-keypad__dot--border | border | 2px solid #71717a | An empty dot. |
--c2-keypad__dot__filled--color | color | #18181b | A dot that holds a digit. |
--c2-keypad__disabled--opacity | opacity | 0.38 | |
Text and languages
The text the component shows, in English. It shows another language when the app adds one with addTranslations, under keypad, and the nearest lang asks for it; any message not translated stays in English. {0}, {1}… stand for the values a message carries. Languages guide.
| Key | English | Values |
|---|---|---|
amount | Amount | — |
pin | PIN | — |
keypad | Keypad | — |
delete | Delete | — |
decimal | Decimal point | — |
entered | {0} of {1} digits entered | {0} count {1} length |
incomplete | Enter all {0} digits. | {0} length |
required | Enter a value. | — |