Solara

1.57.3 · active · verified Thu Apr 16

Solara is an open-source Python library designed to simplify building reactive web applications using ipywidgets and a React-like API. It allows developers to create sophisticated data apps that run seamlessly both within Jupyter Notebooks and as standalone web applications, leveraging frameworks like FastAPI or Starlette. Solara is currently on version 1.57.3 and maintains an active release cadence with frequent updates and bug fixes.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates a simple interactive Solara application with reactive state. It includes a text input and a slider, with dynamic feedback based on word count. Save this as a `.py` file (e.g., `app.py`) and run it using `solara run app.py` from your terminal. For Jupyter Notebooks, append `Page()` to display the component.

import solara

sentence = solara.reactive("Solara makes our team more productive.")
word_limit = solara.reactive(10)

@solara.component
def Page():
    word_count = len(sentence.value.split())
    solara.SliderInt("Word limit", value=word_limit, min=2, max=20)
    solara.InputText(label="Your sentence", value=sentence, continuous_update=True)

    if word_count >= int(word_limit.value):
        solara.Error(f"With {word_count} words, you passed the word limit of {word_limit.value}.")
    elif word_count >= int(0.8 * word_limit.value):
        solara.Warning(f"With {word_count} words, you are close to the word limit of {word_limit.value}.")
    else:
        solara.Success("Great short writing!")

# To run this in a .py file from the command line: `solara run your_app.py`
# To run this in a Jupyter Notebook cell, add the following line at the end:
# Page()

view raw JSON →