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.
pip install reactonVerified import paths — ran on the pinned version, not inferred.
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.
Ensure that arguments passed to widget constructors, especially when creating custom wrappers, precisely align with the widget's traitlets. If issues arise, consider opening an issue on the Reacton GitHub.
Prefer importing `reacton.ipywidgets as w` and using its wrapped components (e.g., `w.Button`) for better type safety, IDE support, and full integration with Reacton's lifecycle.
Embrace Reacton's declarative paradigm by using `reacton.use_state` for local component state and other Reacton hooks for side effects and lifecycle management. Avoid directly modifying widget properties or adding/removing event handlers manually once a component is rendered.