bevy_ui_bits 0.9.0

A mingy and opinionated collection of UI components for Bevy
Documentation

BEVY UI BITS

crates.io license

A mingy and opinionated collection of UI components for Bevy

Usage

use bevy::{color::palettes, prelude::*};
use bevy_ui_bits::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_systems(Startup, spawn_ui)
        .run();
}

fn spawn_ui(mut commands: Commands) {
    commands.spawn(Camera2d::default());

    let font = &Handle::default();

    // Root is the base component for a given UI tree
    let root = Root::congregated();

    // Container is the typical layout component
    let main_container = Container::height(400.0).justify_between();

    // Customize components fluently using a builder-lite pattern
    let title = EmbossedText::large("My Game", font)
        .color(palettes::css::GOLD.into())
        .shadow(palettes::css::MIDNIGHT_BLUE.into());

    // UiButton provides a button with opinionated settings
    let play = UiButton::rectangle().background_color(palettes::css::MIDNIGHT_BLUE.into());
    let play_text = EmbossedText::medium("Play", font);

    let by = SimpleText::medium("By me", font);

    // Use the new Spawn API to spawn UI tree
    commands.spawn((
        root,
        children![(
            main_container,
            children![title, (play, children![play_text]), by]
        )],
    ));
}

Try it out with:

cargo run --example readme --features="bevy/default"

Examples

Basic main menu UI that supports both mouse and keyboard input

main_menu

Try it out with:

cargo run --example main_menu --features="bevy/default"

Simple HUD that features a dynamic text component

hud

Try it out with:

cargo run --example hud --features="bevy/default"

Despawn UI recursively with the RootMarker

despawn

Try it out with:

cargo run --example despawn --features="bevy/default"

Bevy Compatibility

bevy bevy_ui_bits
0.16 0.8, 0.9
0.15 0.7
0.14 0.6
0.13 0.5
0.12 0.4
0.11 0.3
0.10 0.2
0.9 0.1

License

This project is dual-licensed under either:

at your option.

With the exception of the Fira Mono Font, which has its own license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.