| Crates.io | bevy_state_ui |
| lib.rs | bevy_state_ui |
| version | 0.7.0 |
| created_at | 2024-10-25 21:35:00.107175+00 |
| updated_at | 2026-01-22 17:28:50.76257+00 |
| description | A simple UI library for rendering a UI from a given state |
| homepage | |
| repository | https://github.com/ironpeak/bevy_state_ui |
| max_upload_size | |
| id | 1423266 |
| size | 148,543 |
A simple UI library for Bevy that renders UI directly from application state.
Instead of manually managing UI entities, you declare your state and its render function, and bevy_state_ui will automatically keep the UI in sync whenever the state changes.
Add to your Cargo.toml:
[dependencies]
bevy_state_ui = "0.7"
Here’s a minimal app with clickable text that increments a counter:
Run it with:
cargo run --example simple
Normally in Bevy, building UI means:
Node/Text/Button entities in startup systems.Entity IDs or Querys to update them later.This often leads to boilerplate and imperative code. For example:
Res<State> inside systems.BackgroundColor of a button when state.hovered changes.With bevy_state_ui, you flip the model:
impl StateRender for State).This means:
✅ Less boilerplate ✅ More predictable UI (no stale entity state) ✅ A workflow similar to React/Elm/SwiftUI for Bevy
If your mental model of UI is "render(state) → tree of UI nodes", this library gives you exactly that.
State struct that implements:
Resource (so it can live in the ECS world).Hash (to efficiently detect when state changes).StateRender (your declarative UI description).ui_state_render::<State>:
render function.This lets you think of UI as a pure function of state, much like React, Elm, or SwiftUI.