Reacton

1.9.1 · active · verified Thu Apr 16

Reacton is a pure Python library that ports the declarative UI paradigm of React (JavaScript) to the ipywidgets ecosystem. It enables developers to build reusable and composable user interface components within Jupyter notebooks and web applications built with ipywidgets, by offering a declarative approach to state and UI management. It aims to simplify complex UI logic, reduce boilerplate, and enhance maintainability, serving as a foundation for frameworks like Solara. The current version is 1.9.1, with updates released on a feature-ready basis rather than a strict cadence.

Common errors

Warnings

Install

Imports

Quickstart

This example creates a simple button component that updates its click count using Reacton's `use_state` hook and a declarative approach to UI rendering within a Jupyter environment.

import reacton
import reacton.ipywidgets as w
from IPython.display import display

@reacton.component
def ButtonClick():
    clicks, set_clicks = reacton.use_state(0)

    def my_click_handler():
        set_clicks(clicks + 1)

    button = w.Button(
        description=f"Clicked {clicks} times",
        on_click=my_click_handler
    )
    return button

display(ButtonClick())

view raw JSON →