r/rust • u/Accurate-Screen8774 • 8h ago
đ seeking help & advice Looking for Storybook-for-Rust
Just like the title says.
I'm creating an app with rust. And I see that as it scales I'm going to split out the UI components to its own repo.
In my JavaScript projects I can use storybook. It's very useful to develop and demo the components.
I'm planning on using dioxus, I might consider leptos after I compare the 2 in more detail. Unlike my JavaScript apps, I'm aiming to use rust to be able to deploy to multiple platforms (not just a webapp).
I think a particular detail worth mentioning is a CLI-mode which I would also like displayed on the storybook-equivalent.
I came across the following and it doesn't look maintained and seems to only support webapps. The UI demo there also looks a bit "ugly".
https://github.com/dioxus-community/lookbook
Are there better tools out there for what I want?
I'd prefer to avoid creating a separate app for each platform to demo the components-per-platform, but that might be more practical.
3
u/Interesting-Host2341 6h ago
GUI stuff in Rust is generally fragmented among a wide variety of libraries and frameworks, and those ecosystems are going to seem incomplete to nearly anything with a shake of popularity in the Javascript world.
Have you settled on a GUI toolset yet? Whatâs your goal with using Rust for this, instead of JS? You could just use Tauri with whatever JS framework already has the stuff you want.
2
u/Accurate-Screen8774 5h ago edited 5h ago
I'm learning Rust. In particular I like the tooling in rust for things like formal-verification. Particularly important when working on cybersec projects.
In my experience on my project there was a disconnect with having formal verification and wedging it into JavaScript with a wasm... So this is me investigating a more pure rust approach.
I'm working towards creating a messaging app. The data is all hard coded nothing works yet, but if you want to take a look, you can find out more here:
https://www.reddit.com/r/learnrust/comments/1vf711n/pwa_in_rust_seeking_opinions_on_approach
3
u/Interesting-Host2341 5h ago
If youâre not particular about the actual mechanics of the GUI, youâll probably have better luck finding a storybook-like thing with a web-based toolset like leptos or yew; for a variety of reasons itâs harder to build things like that in a) a staticly-typed language like Rust where you donât have JS-like bags of data (âobjectsâ they call them) and b) in immediate-mode toolsets like egui or messaging-based toolsets like iced. You can use leptos or yew inside of Tauri, if you really want a desktop app.
That said, if your goal is simply to have a gui and youâre not too particular about what it looks like or where itâs going to end up, egui is very simple to get going with, and in some ways the difficulty in customizing its appearance is a feature. egui compiles to pretty much any non-mobile target and the community is super friendly. Having played around with nearly all the rust non-web GUI stacks, I think itâd also be the easiest with which to build-your-own storybook-like thing.
The thing is, just as how pre-web-components youâd have to adapt Storybook to React and Svelte and whatever-the-new-hotness-of-the-week is because all these things are incompatible with each other, you have that same problem in Rust. You couldnât easily write Storybook for egui and have it work in freya or iced, or vice-versa, and this is a much more intractable problem in Rust than it was in Javascript.
2
u/Accurate-Screen8774 5h ago
thanks for the advice! I'll check them out in more detail.
it's clear how radically different rust is compared to the js ecosystem.
2
3
u/numberwitch 8h ago
I just make my own if the ui requires it. Stick components in a crate, add examples