change TextField
password default icon styles
#3718
-
Questionhi, I was wondering how can we change I found this issue: #1318 Code samplepassword_field = ft.TextField(
label="Password",
password=True,
can_reveal_password=True,
hint_text="password#0000",
width=400,
height=50,
border_color=ft.colors.TERTIARY,
focused_border_color=ft.colors.PRIMARY,
border_radius=10,
label_style=ft.TextStyle(color=ft.colors.BLUE_100),
hint_style=ft.TextStyle(color=ft.colors.with_opacity(0.35, ft.colors.BLUE_100)),
) Error messageNo response ------------------------------------------------------
|
Beta Was this translation helpful? Give feedback.
Answered by
ndonkoHenri
Jul 27, 2024
Replies: 2 comments 1 reply
-
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) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
stabldev
-
Just pasting an updated code for this, since some properties have since changed in Flet: 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) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can build a custom one: