| Crates.io | bevy_btml |
| lib.rs | bevy_btml |
| version | 0.1.3 |
| created_at | 2026-01-06 19:25:34.444954+00 |
| updated_at | 2026-01-09 01:51:22.054663+00 |
| description | A macro to create Bevy entity-component hierarchies using an HTML-like syntax. |
| homepage | |
| repository | https://github.com/mstjr/bevy_btml |
| max_upload_size | |
| id | 2026580 |
| size | 290,206 |
A macro to create Bevy entity-component hierarchies using an HTML-like syntax.
Even though it was made for UI, it can be used to define any entity-component hierarchy.
btml! Macro: Define your UI hierarchy using a familiar HTML-like structure.<Node width=Val::Percent(100.0) height=Val::Percent(100.0) />
BackgroundColor or TextColor) using content syntax.
<BackgroundColor>Color::BLACK</BackgroundColor>
<Text(new)>"Hello World"</Text>
<children> tag.
btml!(commands,
<Node>
<children>
<Text(new)>"Child Text"</Text>
</children>
</Node>
);
for loops to dynamically create entities.
for item in items {
<Text(new)>item.to_string()</Text>
}
Note: All entities spawned within the loop are children of the parent entity. The loop itself does not create an intermediate wrapper entity.if and else blocks to conditionally spawn entities.
if show_button {
<Button(new)>"Click Me"</Button>
} else {
<Text(new)>"Button Hidden"</Text>
}
use bevy::prelude::*;
use bevy_btml::btml;
fn setup(mut commands: Commands) {
btml!(commands,
<Node
width=Val::Percent(100.0),
height=Val::Percent(100.0),
justify_content=JustifyContent::Center,
align_items=AlignItems::Center,
>
<BackgroundColor>Color::BLACK</BackgroundColor>
<children>
<Text(new)>"Hello Bevy!"</Text>
<TextFont font_size=30.0 />
<TextColor>Color::WHITE</TextColor>
</children>
</Node>
);
}
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.run();
}
You can find examples in the examples/ folder of the repository.
| bevy | bevy_btml |
|---|---|
| 0.17 | 0.1.3 |