[Python] Python 3.11, Flet 0.27 — how to reduce Dropdown size?

Discussão em 'Python' iniciado por Stack, Abril 17, 2025.

  1. Stack

    Stack Membro Participativo

    I'm building a small app and added a Dropdown widget, but it appears disproportionately large compared to the rest of the UI — even though the font size inside is small (screenshot and code attached).

    I suspect the size is affected by the button that triggers the dropdown. I managed to resize the arrow icon, but I can't figure out how to reduce the padding or clickable area around the button itself.

    Additionally, I'm not sure how to control the spacing/margins between the dropdown list items — maybe there's a way to adjust that too?

    Note: Flet 0.27 introduced a new Dropdown component. I didn’t use the older version much, so I can’t compare.

    Question: How can I make the Dropdown smaller (both the button and the expanded list items)?

    self.dropdown_version = ft.Dropdown(
    label="версия",
    label_style=ft.TextStyle(
    size=12,
    font_family="Open Sans",
    ),
    text_style=ft.TextStyle(
    size=12,
    font_family="Open Sans",
    ),
    # expanded_insets=0,
    # text_size=12,
    max_menu_height=300,
    # dense=True,
    content_padding=ft.Padding(top=-10, bottom=-10, right=10, left=10),


    selected_trailing_icon=ft.Icon(
    name=ft.icons.ARROW_DROP_DOWN,
    size=20,
    ),

    trailing_icon=ft.Icon(
    name=ft.icons.ARROW_DROP_UP,
    size=20,
    ),

    options=[
    ft.DropdownOption(key="6.0.1", content=ft.Text(value="6.0.1", size=12, font_family="Open Sans")),
    ft.DropdownOption(key="6.1.1", content=ft.Text(value="6.1.1", size=12, font_family="Open Sans")),
    ft.DropdownOption(key="6.2.1", content=ft.Text(value="6.2.1", size=12, font_family="Open Sans")),
    ft.DropdownOption(key="6.2.2", content=ft.Text(value="6.2.2", size=12, font_family="Open Sans")),
    ]
    )



    [​IMG]

    Continue reading...

Compartilhe esta Página