Skip to main content

IconButton

A Fluent button that shows only an icon.

Example:

fluent.IconButton(fluent.FluentIcons.SETTINGS, tooltip="Settings")
fluent.IconButton(fluent.FluentIcons.SETTINGS, disabled=True)
IconButton
IconButton

Inherits: LayoutControl

Properties

Events

  • on_blur - Called when this button loses focus.
  • on_click - Called when this button is clicked.
  • on_focus - Called when this button receives focus.
  • on_long_press - Called when this button is long-pressed.

Methods

  • focus - Requests focus for this button.

Example​

Fluent IconButton​

Sourceplay_arrowTry Online
import flet_fluent_ui as fluent

import flet as ft


def main(page: ft.Page):
page.title = "Fluent IconButton"

def toggle_favorite(e: ft.Event[fluent.IconButton]):
favorite = e.control.icon == fluent.FluentIcons.STAR
e.control.icon = (
fluent.FluentIcons.STAR_FILLED if favorite else fluent.FluentIcons.STAR
)
status.value = "Added to favorites" if favorite else "Removed from favorites"

def share(e: ft.Event[fluent.IconButton]):
status.value = "Link copied"

status = ft.Text()

page.add(
ft.SafeArea(
content=ft.Column(
controls=[
ft.Row(
controls=[
fluent.IconButton(
fluent.FluentIcons.STAR,
key="favorite",
tooltip="Favorite",
on_click=toggle_favorite,
),
fluent.IconButton(
fluent.FluentIcons.SHARE,
tooltip="Share",
on_click=share,
),
fluent.IconButton(
fluent.FluentIcons.DELETE,
tooltip="Delete",
disabled=True,
),
],
),
status,
],
)
)
)


if __name__ == "__main__":
ft.run(main)
icon_button
Adding to favorites

Properties​

autofocusclass-attributeinstance-attribute​

autofocus: bool = False

Whether this button should be focused on initial display.

iconinstance-attribute​

The icon to show.

icon_sizeclass-attributeinstance-attribute​

icon_size: Number | None = None

The size of icon when it is an IconData.

If None, the theme's icon size for buttons is used.

Events​

on_blurclass-attributeinstance-attribute​

on_blur: ControlEventHandler[IconButton] | None = None

Called when this button loses focus.

on_clickclass-attributeinstance-attribute​

on_click: ControlEventHandler[IconButton] | None = None

Called when this button is clicked.

on_focusclass-attributeinstance-attribute​

on_focus: ControlEventHandler[IconButton] | None = None

Called when this button receives focus.

on_long_pressclass-attributeinstance-attribute​

on_long_press: ControlEventHandler[IconButton] | None = (
    None
)

Called when this button is long-pressed.

Methods​

focusasync​

focus()

Requests focus for this button.