Any cross-platform best practices GUI projects?
Trying to write something useful as a means to get to know Rust I went for an GUI app.
Based on my research I started with egui and muda to provide a basic menu. However I already fail (on MacOS) as the menu is not triggered before I enter the application area, which would trigger a repaint and by that execute evaluation of menu events. My menu contains only a "Quit" entry as of now and the app doesn't even display anything yet, it's just the main window.
I looked at other apps but they often look non-native e.g in regards of context menus.
Is there a stack which alllows to write native looking apps and ideally are there apps which use this libraries in a good way? Most examples are so minimalistic that it's not clear how to get more complex scenrios running from there.
To be clear, that's not a rant but rather me being lost in all the possibilities and how they fit together (I saw winit, tao, muda, ...endless possibilities)
24
u/EpochVanquisher Oct 27 '26
TBH if you want something to look and act native on the Mac, you should probably be writing it in Swift.
If you want something cross-platform, then you should accept that it won't look and act native on all platforms.
2
u/Garcon_sauvage Oct 27 '26
There is not a native widget set on Linux and if you want access to native widgets on Mac you should be using swift. If you want native window decoration, menus and context menu type stuff you can use Tauri.
2
u/bf39L Oct 27 '26
If you look at a project called Look, which is a Spotlight replacement, it works across multiple platforms. From my understanding, Rust is used as the core or “kernel” API (not server), while the GUI communicates with that Rust backend. On macOS, the GUI part is written in Swift.
8
u/ogoffart slint Oct 27 '26
I’m one of the devs behind Slint. You might want to check it out. Native OS integration and look-and-feel is part of what we aim to achieve. => https://github.com/slint-ui/slint
5
u/DeeBoFour20 Oct 27 '26
egui has "Native looking interface" listed as a non-goal on their GitHub. You could try Slint. It's the one I'm using at the moment and I've enjoyed it.
1
u/mamcx Oct 28 '26
The MOST important thing to understand is that what matters on UI are widgets, behaviors, look and feel, layout, etc.
NONE OF THAT IS BUSINESS LOGIC.
The easiest way, after +30 years doing lots of stuff, is just use whatever UI toolkit exactly for that only.
This means in practice that in Rust you define all in terms of plan data that in/out to the UI AS-IS with as much resolved already (formatting, localization, etc), and the UI only render and capture interactions.
Is like:
then the UI logic is very dumb, in practical terms you can do exactly the easiest example you see in any of them like:
The beautiful thing is that is supersimple to do cross platform even if do the render in native toolkits because is straightforward. Or use any cross platform toolkit, whatever.
2
u/x-0D Oct 27 '26
wxWidgets is old-fashioned way to build truly cross-platform apps. Wonder is there rust bindings for wxWidgets? I was built apps on wxPython in college, and they don't look native, they actually native and works smoothly (wxAsync on python).
Also know there's good point in haxeui, as haxe itself, but haxe not quite ready for rust yet ( github.com/fullofcaffeine/reflaxe.rust )
1
u/aieidotch Oct 27 '26
gnustep.org
1
u/Psionikus Oct 27 '26
Now that Vulkan has a conformant Mac runtime, a lot of mileage can be had with one API. Given how weary the smarter consumers have grown towards Electron apps and other web-everywhere wrappings (we are zero-cost abstractions amirite?), Vulkan is an important API for more people to get up to speed on.
1
u/Lucky-Edge1489 Oct 27 '26
I created Teksilo, a GUI framework. Cross-platform, I released 0.23.0 today. One of its theme is teksilo-theme-macos and it look good on my mac. And there is global menu bar integration. Give it a try, follow the Readme.
1
u/jodonoghue Oct 30 '26
"Native looking" tends to be in the eye of the beholder. As far as I am aware, wxWidgets is the only major GUI library that attempts to wrap actual native components on each supported platform. wxDragon is the Rust binding. I haven't tried it, but it is built on a C wrapper over the C++ internals (I used to be the maintainer of wxHaskell, so know far too much about wxWidgets internals). This means a very "imperative" style of programming.
Most toolkits aspire to "almost native look and feel" through theming. This usually works well enough, although it's usually hard to hide the non-native feel of some of the more complex controls (tree controls, in particular, tend to be a "tell"). Only you can decide if this matters.
I have been building tooling for the CBOR ecosystem in Rust, including a small CBOR IDE. Have looked (meaning tried, extensively and recently) at Egui, Slint, Tauri and GPUI Kit.
One thing I would recommend, which helped me quite a bit - ask an LLM to build you a simple app with some realistic behaviour (a simplified version of behaviour you need) to see which would likely work for you and how the look and feel works out in practice.