Introducing Declarative UI in Flet
Flet 1.0 is about more than a facelift. Our goal is to help Python developers build production-grade apps that scale from a handful of screens to hundreds of pages, views, and dialogs.
Dogfooding Flet — building our own products like the Flet mobile app and the Control Gallery — made it clear that the imperative approach becomes hard to manage as apps grow.
That’s why Flet 1.0 introduces a declarative approach alongside the existing imperative API, drawing inspiration from frameworks such as React, SwiftUI, and Jetpack Compose.
Here's a quick look at a counter app written declaratively:
import flet as ft
@ft.component
def App():
count, set_count = ft.use_state(0)
return ft.Row(
controls=[
ft.Text(value=f"{count}"),
ft.Button("Add", on_click=lambda: set_count(count + 1)),
],
)
ft.run(lambda page: page.render(App))
Keep reading to see how it works and how you can start using it today.