Skip to content

About

Streamlit for D. Write data apps as a plain D function that reruns from top to bottom on every interaction, the way you write them in Python with Streamlit, producing one self-contained binary: the web UI, charts, maps, math rendering and fonts are compiled in, so it runs offline and deploys by copying a file.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

11 Commits

Folders and files

Repository files navigation

streamlitd

Streamlit for D. Write data apps as a plain D function that reruns from top to bottom on every interaction, the way you write them in Python with Streamlit. dub build produces one self-contained binary: the web UI, charts, maps, math rendering and fonts are compiled in, so it runs offline and deploys by copying a file.

import streamlitd;

void app(St st)
{
    st.title("Hello 👋");
    auto name = st.textInput("Your name", "World");
    auto n = st.slider("Times", 1, 10, 3);
    if (st.button("Greet", type: "primary"))
        st.success("Hello " ~ name ~ "!");
}

mixin StreamlitMain!app;
dub run                          # → http://localhost:8501

📚 Documentation: docs/ has the getting started guide, the tutorial and the Python → D cheat sheet.

Screenshots

Tutorial dashboard Sales dashboard from the tutorial: cached CSV, filters, metrics, charts Widgets Every input widget: text, numbers, sliders, selects, dates, colors
Data DataFrames: sortable, searchable tables with CSV export Charts Charts: line, bar, area, scatter and any Vega-Lite spec
Data editor Data editor: edit, add and delete rows Plotly Plotly figures with selection events
Chat Chat UI and multipage navigation (dark mode) Dialog Dialogs, fragments and partial reruns
Math and code LaTeX (KaTeX) and syntax-highlighted code Map Maps (Leaflet, configurable tiles)
Layout Layout: columns, tabs, expanders, containers, popovers Login Login: password users and OIDC single sign-on
Controls Themed controls: searchable selects, calendar, time list and color picker (no native browser pop-ups) win95 × paper Design × scheme: win95 × paper

8 design styles × 8 color schemes × light/dark (theming): streamlit, terminal, retro, win95, XP, brutalist, material and glass, each usable with any color scheme:

Design styles

terminal × solarized terminal × solarized, dark win95 × paper win95 × paper

Features

  • Streamlit's programming model: reruns, widget state, st.session, callbacks, forms, st.rerun/st.stop, cacheData/cacheResource, multipage st.navigation, query params.
  • About 70 elements and widgets:
    • text, markdown (with :color[...] and $math$), alerts, metrics, JSON, progress, spinner, toast
    • all input widgets, file upload and download, chat input and messages
    • pills, segmented control, feedback
  • Layout: sidebar, columns, tabs, expanders, containers, popovers, st.empty, dialogs, status containers, fragments with runEvery auto-refresh.
  • Data: a DataFrame type (structs, CSV, JSON; filter, sort, groupBy), interactive tables, a data editor, Vega-Lite charts, Plotly, maps, images, audio, video.
  • Theming: 8 design styles (terminal, retro, win95, XP, brutalist, material, glass, streamlit) × 8 color schemes × light/dark, custom colors and fonts (Streamlit-compatible [theme] keys), and a viewer appearance menu.
  • Production:
    • worker threads, so CPU-heavy sessions don't block other users
    • config.toml and secrets.toml (existing .streamlit/ files work)
    • base URL path for reverse proxies, origin checks, session limits
    • Docker image, health endpoint
  • Auth: sign-up with automatic password hashing (the first account is admin), invites or approval, roles (st.user.hasRole, st.requireRole), a ready-made admin panel (st.userAdmin()), account page, login throttling, CLI user commands; plus users in secrets.toml and OIDC (Google, Entra ID, Keycloak, …): Authentication.
  • App shell and business UI beyond Streamlit: top navigation with sections, breadcrumbs, a header bar, user menu, footer and banners; menu buttons, pagination, cards, stepper, timeline, tags, tree select, date ranges and more: Layout, More elements.
  • Custom components compatible with Streamlit's component protocol.
  • Extensible: add your own color schemes, design styles and native widgets, in D or in config.toml: Extending.
  • JSON API endpoints next to the UI (FastAPI-style typed REST interfaces via vibe.d), on the same port and login, with an optional generated OpenAPI document and Swagger UI at /docs: API endpoints.
  • Testing: headless AppTest for unit tests; Playwright end-to-end tests.
  • Branding: streamlitd's own favicon by default; set yours per app ([server] favicon, --favicon) or per page (st.setPageConfig(icon:) with an emoji, URL or image file; multipage apps show the page icon).

Documentation

Getting started install, first app, project layout
Tutorial build a dashboard step by step
Core concepts reruns, state, callbacks, forms, fragments, caching, threads
Layout & navigation · Data & charts · Theming guides
Configuration · Deployment (Docker, nginx, systemd) · Authentication running in production
Custom components · Extending · JSON API endpoints · Testing extending and testing
Porting from Python · Cheat sheet · API reference reference
Troubleshooting · Architecture FAQ and internals

Requirements

  • dub and a D compiler. Tested with LDC 1.36 and DMD 2.114.
  • OpenSSL 3 and zlib at runtime, as with every vibe.d app.

Repository layout

source/streamlitd/   the library (server, session, St API, DataFrame, charts, auth, ...)
assets/              frontend: index.html, app.js, style.css, vendor/ (bundled JS libraries)
examples/            runnable apps: hello, widgets, data, multipage, themes, prod, fragments, extras, auth, tutorial, api, custom
docs/                documentation and screenshots
tests/unit/          headless AppTest suites (dub test)
tests/e2e/           Playwright end-to-end tests and the screenshot script
tools/               asset list, API docs and doc-snippet generators/checkers

Tests

./run-tests.sh      # D unit tests + Playwright e2e tests + compile every doc snippet

License

MIT. Bundled third-party libraries are listed in assets/vendor/licenses.

About

Streamlit for D. Write data apps as a plain D function that reruns from top to bottom on every interaction, the way you write them in Python with Streamlit, producing one self-contained binary: the web UI, charts, maps, math rendering and fonts are compiled in, so it runs offline and deploys by copying a file.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages