Skip to content

change TextField password default icon styles #3718

Answered by ndonkoHenri
stabldev asked this question in Q&A
Discussion options

You must be logged in to vote

You can build a custom one:

import flet as ft


def main(page: ft.Page):
    def handle_password_icon_click(e):
        if password_field.password:
            password_field.password = False
            password_field.suffix.icon = ft.icons.VISIBILITY
        else:
            password_field.password = True
            password_field.suffix.icon = ft.icons.VISIBILITY_OFF
        password_field.update()

    password_field = ft.TextField(
        password=True,
        suffix=ft.IconButton(
            icon=ft.icons.VISIBILITY_OFF,
            icon_color=ft.colors.GREEN,
            on_click=handle_password_icon_click,
        ),
    )
    page.add(password_field)


ft.app(target=main)

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@stabldev
Comment options

Answer selected by stabldev
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
help wanted Extra attention is needed
3 participants