← All Workshops

MudEngine Part 5: Polished UI with dioxus-components

Congratulations!

You replaced hand-rolled HTML with a real component library — in about 45 minutes.

What we achieved:

  • Card — semantic container for the room description with header, separator, and content regions
  • RoomCell — a custom component for grid cells, ready to show player indicators in multiplayer
  • Button — a clickable D-pad that replaces typed navigation for most interactions
  • Input — a styled command input that matches the other components
  • Theme system — components use CSS variables, so switching colours or dark mode is a one-line change

The game engine is untouched. The same World, look(), and go() power the app. Only the UI layer changed — which is exactly the kind of refactoring real projects do when they adopt a design system.

On to Part 6, where we take this polished UI and make it multiplayer with WebSockets! 🏰

📚 What we learned
ConceptHow we used it
dx components addPulling individual styled components into the project
dioxus-primitives git depAdding the unstyled base library from GitHub
mod components;Declaring the auto-generated src/components/ module
Card / CardHeader / CardContentStructured content panels with theme styling
RoomCell (custom)Reusable grid cell with name and active props, extensible for multiplayer
Button / ButtonVariantClickable actions with consistent theming
InputThemed form input with all standard event handlers
SeparatorHorizontal rule that respects the theme
CSS modules + #[css_module]Scoped component styles that don't leak