Crate bevy_ecss

source ·
Expand description

§Bevy

MIT/Apache 2.0 Realease Doc Rust Crate Bevy tracking

§Bevy ECSS

§What is Bevy ECSS?

Bevy ECSS is a crate which allows the usage of a subset of CSS to interact with bevy_ecs. It’s mainly aimed to apply styling on bevy_ui but it can be used by any component by implementing custom properties.

§Why the name?

Just because Bevy ECS + CSS is a perfect fit!

§Docs site

Reference guide, examples and more available here: docs

§Usage

To use Bevy ECSS just add a StyleSheet with a loaded css file to any entity and all style sheet rules will be applied to the entity and all its descendants (children of children of children and so on).

use bevy::prelude::*;
use bevy_ecss::prelude::*;

fn setup_awesome_ui(root: Entity, mut commands: Commands, asset_server: Res<AssetServer>) {
    commands
        .entity(root)
        .insert(StyleSheet::new(asset_server.load("sheets/awesome.css")));
}

That’s it, now your UI will indeed look awesome!

§Bevy support table

bevybevy_ecss
0.80.1
0.90.2
0.100.3
0.110.4
0.120.5
0.120.6
0.130.7

§Contributing

Got some idea, feedback, question or found any bug? Feel free to open an issue at any time!

§License

Bevy ECSS is dual-licensed under either:

This means you can select the license you prefer! This dual-licensing approach is the de-facto standard in the Rust ecosystem and there are very good reasons to include both.

Modules§

  • use bevy_ecss::prelude::*; to import common components, and plugins and utility functions.

Structs§

  • Sets the entities class to be matched by selectors in oncss.
  • Plugin which add all types, assets, systems and internal resources needed by bevy_ecss. You must add this plugin in order to use bevy_ecss.
  • A list of PropertyToken which was parsed from a single property.
  • A selector parsed from a css rule. Each selector has a internal hash used to differentiate between many rules in the same sheet.
  • Represents a single rule inside a style sheet with a Selector which determines which entities should be applied the PropertyValues.
  • Applies a StyleSheetAsset on the entity which has this component.
  • A cascading style sheet (css) asset file.

Enums§

  • Errors which can happens while parsing css into Selector or Property.
  • System sets used by bevy_ecss systems
  • A property value token which was parsed from a CSS rule.
  • Represents a selector element on a style sheet rule. A single selector can have multiple elements, for instance a selector of button.enabled Would generated two elements, one for button and another for .enabled.

Traits§