Skip to content

Password Field

The password field is a text field for secrets. It hides the input and lets the user reveal it. Never send a stored secret back to the browser: only fill in a value which the user has just entered.

Password Field

func view(wnd core.Window) core.View {
    password := core.AutoState[string](wnd).Init(func() string { return "correct horse" })
    repeated := core.AutoState[string](wnd).Init(func() string { return "correct house" })

    return VStack(
        PasswordField("Password", password.Get()).
            InputValue(password).
            SupportingText("At least 12 characters").
            FullWidth(),
        PasswordField("Repeat password", repeated.Get()).
            InputValue(repeated).
            ErrorText("The passwords do not match").
            FullWidth(),
    ).Gap(L16).Frame(Frame{Width: L320})
}

Constructors

func PasswordField(label string, value string) TPasswordField

PasswordField represents a secret entered by the user.

Methods

MethodDescription
AccessibilityLabel(label string) DecoredViewAccessibilityLabel sets an accessibility label for screen readers.
AutoComplete(autoComplete bool) TPasswordFieldAutoComplete enables or disables browser autocomplete for the field.
Autocomplete(tags string) TPasswordFieldAutocomplete defines the autocomplete tags of the input
Border(border Border) DecoredViewBorder sets the border styling of the field.
Debounce(enabled bool) TPasswordFieldDebounce is enabled by default.
DebounceTime(d time.Duration) TPasswordFieldDebounceTime sets a custom debouncing time when entering text.
Disabled(disabled bool) TPasswordFieldDisabled enables or disables the field.
ErrorText(text string) TPasswordFieldErrorText sets the error message displayed when validation fails.
Frame(frame Frame) DecoredViewFrame sets the layout frame for the field.
FullWidth() TPasswordFieldFullWidth expands the field to take up the full available width.
ID(id string) TPasswordFieldID sets a unique identifier for the field.
InputValue(input *core.State[string]) TPasswordFieldInputValue binds the password field to the given state for two-way data binding.
KeydownEnter(fn func()) TPasswordFieldKeydownEnter sets a callback function to be triggered when the Enter key is pressed.
Label(label string)Label sets the field label.
Lines(lines int) TPasswordFieldLines are by default at 0 and enforces a single line text field.
Padding(padding Padding) DecoredViewPadding sets the padding around the field.
Style(s TextFieldStyle) TPasswordFieldStyle sets the wanted style.
SupportingText(text string) TPasswordFieldSupportingText sets helper text displayed below the field.
Value(value string) TPasswordFieldValue sets the initial value of the password field.
Visible(v bool) DecoredViewVisible sets the field’s visibility.
WithFrame(fn func(Frame) Frame) DecoredViewWithFrame applies a transformation function to the field’s frame.

Related