Skip to content

[Question] Can someone explain me about styling the disabled ElevatedButtons #4783

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

You must be logged in to vote

Below is a simple example, in which the text style of the button's text depends on it's state (whether disabled or not).

import flet as ft


def main(page: ft.Page):
    def handle_switch_change(e):
        my_button.disabled = e.control.value
        page.update()

    my_button = ft.ElevatedButton(
        text="Toggle the switch to see my text style change",
        style=ft.ButtonStyle(
            text_style={
                ft.ControlState.DISABLED: ft.TextStyle(
                    size=20, weight=ft.FontWeight.BOLD
                ),
                ft.ControlState.DEFAULT: ft.TextStyle(size=10, italic=True),
            }
        ),
    )
    page.add(
        my_button,
        ft

Replies: 1 comment 1 reply

Comment options

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

Answer selected by Kiueeukou
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
2 participants