PasswordBox
A Fluent password box: a text box that hides what is typed, with a button to reveal it.
Example:
fluent.PasswordBox(placeholder="Password", value="secret")
fluent.PasswordBox(
placeholder="PIN", reveal_mode=fluent.PasswordRevealMode.HIDDEN
)

Inherits: LayoutControl
Properties
autofocus- Whether this password box should be focused on initial display.error_text- An error message shown in red below the box, which also gets a red underline.placeholder- The hint shown whilevalueis empty.prefix- An icon or control shown before the password.read_only- Whether the password can be selected but not changed.reveal_mode- Whether and how the user can see the password.value- The current password.
Events
Methods
focus- Requests focus for this password box.
Example
Fluent PasswordBox
import flet_fluent_ui as fluent
import flet as ft
def main(page: ft.Page):
page.title = "Fluent PasswordBox"
def handle_change(e: ft.Event[fluent.PasswordBox]):
length = len(e.control.value)
strength.value = (
"Strength: strong" if length >= 12 else f"Strength: weak ({length}/12)"
)
strength = ft.Text("Strength: weak (0/12)")
page.add(
ft.SafeArea(
content=ft.Column(
width=300,
controls=[
fluent.PasswordBox(
key="password",
placeholder="New password",
reveal_mode=fluent.PasswordRevealMode.PEEK_ALWAYS,
on_change=handle_change,
),
strength,
],
)
)
)
if __name__ == "__main__":
ft.run(main)

Properties
autofocusclass-attributeinstance-attribute
autofocus: bool = FalseWhether this password box should be focused on initial display.
error_textclass-attributeinstance-attribute
error_text: str | None = NoneAn error message shown in red below the box, which also gets a red underline.
Set it to tell the user that the value is not valid, and set it to None
to hide it.
placeholderclass-attributeinstance-attribute
placeholder: str | None = NoneThe hint shown while value is empty.
prefixclass-attributeinstance-attribute
prefix: IconDataOrControl | None = NoneAn icon or control shown before the password.
read_onlyclass-attributeinstance-attribute
read_only: bool = FalseWhether the password can be selected but not changed.
reveal_modeclass-attributeinstance-attribute
reveal_mode: PasswordRevealMode = PasswordRevealMode.PEEKWhether and how the user can see the password.
Events
on_blurclass-attributeinstance-attribute
on_blur: ControlEventHandler[PasswordBox] | None = NoneCalled when this password box loses focus.
on_changeclass-attributeinstance-attribute
on_change: ControlEventHandler[PasswordBox] | None = NoneCalled when the password changes.
The data property of the event handler argument
contains the new password.
on_focusclass-attributeinstance-attribute
on_focus: ControlEventHandler[PasswordBox] | None = NoneCalled when this password box receives focus.
on_submitclass-attributeinstance-attribute
on_submit: ControlEventHandler[PasswordBox] | None = NoneCalled when the user submits the password, for example by pressing Enter.