- richer layout control
- client-side interaction
- a third-party charting or table library
- a page that feels closer to a real product UI than a dashboard widget tree
app.theme(...)for branding and paletteapp.add_page(...)for TSX pages@capsule/pagehooks likeuseData,useCollection,useTheme, anduseCapsule- extra npm packages for custom visualizations
1. Theme the app
Start by defining the app theme in Python:preset gives you a sensible base theme. In practice, most apps start with a preset and override just a few fields such as primary, accent, and fonts.
2. Register a React page
Add a page that points at a TSX file:packages:
3. Expose data for the page
React pages usually consume the same building blocks as DSL pages: collections and data handlers.4. Create pages/dashboard.tsx
useData("stats")reads a named data handleruseCollection("contacts", ...)reads a collection with paging and sortinguseTheme()gives you the current Capsule theme values so the page matches the rest of the app
useData(name, options)for data handlersuseCollection(name, options)for collection queriesuseTheme()for app colors, fonts, and radiiuseCapsule()for current app and user context
useData accepts params:
5. Run and iterate
When you run:.capsule/types so the local page environment has the right type stubs while you iterate.
A practical workflow is:
- tweak the Python data handler or collection
- save the file and refresh the page
- tweak the TSX component
- save again and keep iterating
6. When to choose React over the DSL
Use the Python DSL when:- tables, charts, metrics, and settings widgets are enough
- you want the fastest path from Python to UI
- the layout is mostly static
- you need custom interaction logic
- you want richer visual polish
- you need external packages
- the page should feel like a small frontend app
Full example
Next steps
- Use React pages with durable data from Collections And Scopes
- Add background status views with Tasks And Schedules
- See UI And Pages Reference for the DSL widgets and React page patterns