SecretInput
Use the SecretInput to let users enter write-only secrets, such as API tokens. After a secret is stored, the input shows a fixed mask with a "Replace" button, so the secret can be changed but never displayed again.
Import
import { SecretInput } from '@dynatrace/strato-components/forms';
Demo
This is the simplest version of the SecretInput, which is uncontrolled and therefore handles its state internally. You can also set a specific initial value using the defaultValue prop.
Control state
The SecretInput can also be controlled, meaning that you can handle the state. To do so, you need to use the onChange prop to provide a handler that is called when the internal state of the input changes. You also need to assign the value from the state to the SecretInput by setting the value prop.
Locked mode
For security reasons, form fields with sensitive credentials cannot be refilled with persisted data once saved. For this purpose the SecretInput can be set to locked mode by simply passing null to the value or defaultValue prop. Locked mode is commonly used for forms with backend validation that requires sensitive credentials to be reentered and resubmitted when editing a related form field. Clicking on "Replace" emits an onChange event with an empty string payload ('') and sets the component back to input mode.
Validation
For validation patterns including custom hints and errors, see show custom hints and errors in the FormField documentation.