https://github.com/pydantic/FastUI Skip to content Toggle navigation Sign in * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code Explore + All features + Documentation + GitHub Skills + Blog * Solutions For + Enterprise + Teams + Startups + Education By Solution + CI/CD & Automation + DevOps + DevSecOps Resources + Learning Pathways + White papers, Ebooks, Webinars + Customer Stories + Partners * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} pydantic / FastUI Public * Notifications * Fork 208 * Star 5k * Build better UIs faster. fastui-demo.onrender.com License MIT license 5k stars 208 forks Branches Tags Activity Star Notifications * Code * Issues 69 * Pull requests 19 * Actions * Security * Insights Additional navigation options * Code * Issues * Pull requests * Actions * Security * Insights pydantic/FastUI This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. main BranchesTags Go to file Code Folders and files Last commit Last Name Name message commit date Latest commit History 131 Commits .github .github demo demo src src .eslintrc.cjs .eslintrc.cjs .gitignore .gitignore .pre-commit-config.yaml .pre-commit-config.yaml .prettierignore .prettierignore LICENSE LICENSE Makefile Makefile README.md README.md bump_npm.py bump_npm.py package-lock.json package-lock.json package.json package.json pyproject.toml pyproject.toml screenshot.png screenshot.png tsconfig.json tsconfig.json View all files Repository files navigation * README * MIT license * Security FastUI CI pypi versions license Please note: FastUI is still an active work in progress, do not expect it to be complete. The Principle (short version) You can see a simple demo of an application built with FastUI here. FastUI is a new way to build web application user interfaces defined by declarative Python code. This means: * If you're a Python developer -- you can build responsive web applications using React without writing a single line of JavaScript, or touching npm. * If you're a frontend developer -- you can concentrate on building magical components that are truly reusable, no copy-pasting components for each view. * For everyone -- a true separation of concerns, the backend defines the entire application; while the frontend is free to implement just the user interface At its heart, FastUI is a set of matching Pydantic models and TypeScript interfaces that allow you to define a user interface. This interface is validated at build time by TypeScript and pyright/mypy and at runtime by Pydantic. The Practice -- Usage FastUI is made up of 4 things: * fastui PyPI package -- Pydantic models for UI components, and some utilities. While it works well with FastAPI it doesn't depend on FastAPI, and most of it could be used with any python web framework. * @pydantic/fastui npm package -- a React TypeScript package that lets you reuse the machinery and types of FastUI while implementing your own components * @pydantic/fastui-bootstrap npm package -- implementation/ customisation of all FastUI components using Bootstrap * @pydantic/fastui-prebuilt npm package (available on jsdelivr.com CDN) providing a pre-built version of the FastUI React app so you can use it without installing any npm packages or building anything yourself. The Python package provides a simple HTML page to serve this app. Here's a simple but complete FastAPI application that uses FastUI to show some user profiles: from datetime import date from fastapi import FastAPI, HTTPException from fastapi.responses import HTMLResponse from fastui import FastUI, AnyComponent, prebuilt_html, components as c from fastui.components.display import DisplayMode, DisplayLookup from fastui.events import GoToEvent, BackEvent from pydantic import BaseModel, Field app = FastAPI() class User(BaseModel): id: int name: str dob: date = Field(title='Date of Birth') # define some users users = [ User(id=1, name='John', dob=date(1990, 1, 1)), User(id=2, name='Jack', dob=date(1991, 1, 1)), User(id=3, name='Jill', dob=date(1992, 1, 1)), User(id=4, name='Jane', dob=date(1993, 1, 1)), ] @app.get("/api/", response_model=FastUI, response_model_exclude_none=True) def users_table() -> list[AnyComponent]: """ Show a table of four users, `/api` is the endpoint the frontend will connect to when a user visits `/` to fetch components to render. """ return [ c.Page( # Page provides a basic container for components components=[ c.Heading(text='Users', level=2), # renders `