Prefab

raw JSON →
0.19.1 verified Sat May 09 auth: no python

Prefab is a generative UI framework for Python by PrefectHQ. It allows building interactive web UIs with pure Python, using reactive components. Current version: 0.19.1, requires Python >=3.10. Release cadence is active with frequent minor/patch releases.

pip install prefab-ui
error ModuleNotFoundError: No module named 'prefab_ui'
cause Importing using the PyPI package name instead of the correct module name.
fix
Replace import prefab_ui with import prefab.
error AttributeError: module 'prefab' has no attribute 'Button'
cause Trying to import a component directly from the top-level prefab module.
fix
Use from prefab.components import Button.
error TypeError: App.__init__() got an unexpected keyword argument 'something'
cause Passing unsupported arguments to App constructor; App only accepts components and basic config.
fix
Check App signature: App(*components, title='', ...).
error ValueError: 'from_model' requires a Pydantic model class
cause Form.from_model() called with an object that is not a Pydantic BaseModel subclass.
fix
Ensure the class inherits from pydantic.BaseModel.
error prefab.exceptions.PrefabRuntimeError: Reactive state not bound to component
cause Using a reactive state variable outside a component's render context.
fix
Access reactive state only within component callbacks or render functions.
gotcha Import as `prefab` not `prefab_ui` – the PyPI package name and import name differ.
fix Use `import prefab` or `from prefab import ...`
gotcha Components must be imported from `prefab.components` submodule, not directly from `prefab`.
fix Use `from prefab.components import Button, Form, ...`
gotcha Reactive state management requires understanding `prefab.state` and reactive variables; misuse can cause silent UI failures.
fix Use `prefab.state.State` or `prefab.state.Reactive` for mutable state.
gotcha The `Form.from_model` runtime prefill feature was added in v0.19.1; earlier versions do not support `defaults` kwarg.
fix Upgrade to 0.19.1+ or implement prefill manually.
gotcha Charts default to `show_legend=True` only from v0.17.0+; earlier versions had no legend.
fix Upgrade to 0.17.0+ or set `show_legend=True` explicitly.

Minimal app with a button, served locally.

import prefab
from prefab import App, components

app = App(
    components.Button(text="Hello, World!")
)

if __name__ == "__main__":
    app.serve()