Bevy_hui
Build bevy_ui design in pseudo Html. Keep your logic in bevy, while iterating fast on design
with hot reloading. Create reusable templates in the style of Web Components.
https://github.com/user-attachments/assets/4eb22305-7762-404e-9093-806b6a155ede
Features
- In build support for conditional styles and transitions. Hover animations by default!
- Any value can be a dynamic property and injected into a template at runtime. (recursive!)
- Simple but effective event system. Register any bevy system via function binding and use it
in your templates
on_press="start_game". - No widgets, no themes. Just bevy UI serialized with all the tools necessary to build anything in a reusable manor.
Example
Like most crates, don't forget to register the plugin!
app.add_plugins;
Getting Started (Bevy html syntax Cheatsheet)
Create your first component template with external properties!
<!-- /assets/my_button.html-->
greet
Press me
#123
#503
{text}
Register your component and make a custom binding
To use your new component in any other templates, we have to register it first.
You can either use the HuiAutoLoadPlugin feature (experimental), which
is great for simple components or register the component yourself in a startup system.
This also allows for custom spawning functions. With is great if you need to add custom components as well!
Putting it all together
Time to be creative. Include your component in the next template.
<!-- menu.html -->
My Game
...
...
Spawning your Template
Required components make it super simple.
Examples and Widgets
Experimental widget crate:
In addition to the base crate there is also the bevy_hui_widgets crate. It offers some basic
widgets functionality without providing a template. Each Widget requires some kind of setup/hierarchy
to work, but the user is in full control over the Template and can style and extend it however they see
fit.
Imagine html <select>, but you provide the template and style of the underlying buttons and containers.
Checkout the widget example.
# basic menu demo
# using the widget helper crate to make some basic widgets like sliders, inputs, selections
Help wanted
I do not plan to offer any widgets on the templating side, but I would like to have common components and system for a general reusable widget toolkit like sliders, drop downs, draggable and so on.
Checkout the examples, if you come up with some really cool widgets, I would be happy
to include them into the upcoming bevy_hui_widgets crate.
More examples
I am not the greatest designer. I am actively looking for some really fancy and cool examples, using this crate to include in the example crate.
Known limitations and Pitfalls
- Any manual changes to bevy's styling components will be overwritten
- Do not recursive import. [mem stonks, bug]
- One root node per component.
- Reloading a component template sometimes breaks logic on a higher level template. Simply reloading the higher level template fixes this for now. Needs further investigation.