bevy_egui 0.41.0

A plugin for Egui integration into Bevy
Documentation
[![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direct.svg)](https://stand-with-ukraine.pp.ua)

**Hey!** I'm the author of the crate, and I was born in Mariupol, Ukraine. When russians started the war in 2014, I moved to Kyiv. My parents, who had been staying in Mariupol till the start of the full-scale invasion, barely escaped the city alive. By the moment of writing (June 24th, 2026), we had [2225 air raid alerts in Kyiv, and russians managed to bomb the city 873 times](https://air-alarms.in.ua/en/region/kyiv?only-region-center#statistic).

**If you are using this crate, please consider donating to any of the listed funds (see the banner above), that will mean a lot to me.**

You can also support me directly via [Patreon](https://patreon.com/vladbat00?utm_medium=unknown&utm_source=join_link&utm_campaign=creatorshare_creator&utm_content=copyLink).

# `bevy_egui`

[![Crates.io](https://img.shields.io/crates/v/bevy_egui.svg)](https://crates.io/crates/bevy_egui)
[![Documentation](https://docs.rs/bevy_egui/badge.svg)](https://docs.rs/bevy_egui)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/bevyengine/bevy/blob/master/LICENSE)
[![Downloads](https://img.shields.io/crates/d/bevy_egui.svg)](https://crates.io/crates/bevy_egui)
[![CI](https://github.com/vladbat00/bevy_egui/actions/workflows/check.yml/badge.svg?branch=main)](https://github.com/vladbat00/bevy_egui/actions)

This crate provides an [Egui](https://github.com/emilk/egui) integration for the [Bevy](https://github.com/bevyengine/bevy) game engine.

**Trying out:**

A basic WASM example is live at [vladbat00.github.io/bevy_egui/ui](https://vladbat00.github.io/bevy_egui/ui/).

**Features:**
- Desktop and web platforms support
- Clipboard
- Opening URLs
- Multiple windows support and split-screen support (see [./examples/two_windows.rs]https://github.com/vladbat00/bevy_egui/blob/v0.41.0/examples/two_windows.rs and [./examples/split_screen.rs]https://github.com/vladbat00/bevy_egui/blob/v0.41.0/examples/split_screen.rs)
- Paint callback support (see [./examples/paint_callback.rs]https://github.com/vladbat00/bevy_egui/blob/v0.41.0/examples/paint_callback.rs)
- Mobile web virtual keyboard (still rough around the edges and only works without `prevent_default_event_handling` set to `false` in the `WindowPlugin` settings)
- Accesskit support

![bevy_egui](bevy_egui.png)

## Dependencies

On Linux, this crate requires certain parts of [XCB](https://xcb.freedesktop.org/) to be installed on your system. On Debian-based systems, these can be installed with the following command:

```bash
sudo apt install libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev
```

## Usage

Here's a minimal usage example:
```toml
# Cargo.toml
[dependencies]
bevy = "0.19.0"
bevy_egui = "0.41.0"
```

```rust
use bevy::prelude::*;
use bevy_egui::{egui, EguiContexts, EguiPlugin, EguiPrimaryContextPass};

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugins(EguiPlugin::default())
        .add_systems(Startup, setup_camera_system)
        .add_systems(EguiPrimaryContextPass, ui_example_system)
        .run();
}

fn setup_camera_system(mut commands: Commands) {
    commands.spawn(Camera2d);
}

fn ui_example_system(mut contexts: EguiContexts) -> Result {
    egui::Window::new("Hello").show(contexts.ctx_mut()?, |ui| {
        ui.label("world");
    });
    Ok(())
}
```

Note that this example uses Egui in the [multi-pass mode]((https://docs.rs/egui/0.31.1/egui/#multi-pass-immediate-mode)).
If you don't want to be limited to the `EguiContextPass` schedule, you can use the single-pass mode,
but it may get deprecated in the future.

For more advanced examples, see the [examples](#Examples) section below.

## Examples

To run an example, use the following command (you may replace `ui` with a name of another example):

```bash
cargo run --example ui
```

### ui ([live page]https://vladbat00.github.io/bevy_egui/ui, source: [examples/ui.rs]https://github.com/vladbat00/bevy_egui/blob/v0.41.0/examples/ui.rs)

Showcasing some more advanced UI, rendering images, hidpi scaling.

### absorb_input ([live page]https://vladbat00.github.io/bevy_egui/absorb_input, source: [examples/absorb_input.rs]https://github.com/vladbat00/bevy_egui/blob/v0.41.0/examples/absorb_input.rs)

Demonstrating the available options for absorbing input when Egui is using pointer or keyboard.  

### color_test ([live page]https://vladbat00.github.io/bevy_egui/color_test, source: [examples/color_test.rs]https://github.com/vladbat00/bevy_egui/blob/v0.41.0/examples/color_test.rs)

Rendering test from [egui.rs](https://egui.rs). We don't fully pass it, help is wanted ([#291](https://github.com/vladbat00/bevy_egui/issues/291)).

### side_panel ([live page]https://vladbat00.github.io/bevy_egui/side_panel, source: [examples/side_panel.rs]https://github.com/vladbat00/bevy_egui/blob/v0.41.0/examples/side_panel.rs)

Showing how to display an Egui side panel and transform a camera with a perspective projection to make rendering centered relative to the remaining screen area.

### split_screen ([live page]https://vladbat00.github.io/bevy_egui/split_screen, source: [examples/split_screen.rs]https://github.com/vladbat00/bevy_egui/blob/v0.41.0/examples/split_screen.rs)

Demonstrating how to render multiple Egui contexts, attaching them to several cameras that target the same window.

### render_egui_to_image ([live page]https://vladbat00.github.io/bevy_egui/render_egui_to_image, source: [examples/render_egui_to_image.rs]https://github.com/vladbat00/bevy_egui/blob/v0.41.0/examples/render_egui_to_image.rs)

Rendering UI to an image (texture) and then using it as a mesh material texture.

### render_to_image_widget ([live page]https://vladbat00.github.io/bevy_egui/render_to_image_widget, source: [examples/render_to_image_widget.rs]https://github.com/vladbat00/bevy_egui/blob/v0.41.0/examples/render_to_image_widget.rs)

Rendering to a texture with Bevy and showing it as an Egui image widget.

### two_windows (source: [examples/two_windows.rs]https://github.com/vladbat00/bevy_egui/blob/v0.41.0/examples/two_windows.rs)

Setting up two windows with an Egui context for each.

### paint_callback ([live page]https://vladbat00.github.io/bevy_egui/paint_callback, source: [examples/paint_callback.rs]https://github.com/vladbat00/bevy_egui/blob/v0.41.0/examples/paint_callback.rs)

Using Egui paint callbacks.

### simple ([live page]https://vladbat00.github.io/bevy_egui/simple, source: [examples/simple.rs]https://github.com/vladbat00/bevy_egui/blob/v0.41.0/examples/simple.rs)

The minimal usage example from this readme.

### run_manually ([live page]https://vladbat00.github.io/bevy_egui/run_manually, source: [examples/run_manually.rs]https://github.com/vladbat00/bevy_egui/blob/v0.41.0/examples/run_manually.rs)

The same minimal example demonstrating running Egui passes manually.

## See also

- [`jakobhellermann/bevy-inspector-egui`]https://github.com/jakobhellermann/bevy-inspector-egui

## Bevy support table

**Note:** if you're looking for a `bevy_egui` version that supports `main` branch of Bevy, check out [open PRs](https://github.com/vladbat00/bevy_egui/pulls), there's a great chance we've already started working on the future Bevy release support.

| bevy | bevy_egui |
|------|-----------|
| 0.19 | 0.40-0.41 |
| 0.18 | 0.39      |
| 0.17 | 0.37-0.38 |
| 0.16 | 0.34-0.36 |
| 0.15 | 0.31-0.33 |
| 0.14 | 0.28-0.30 |
| 0.13 | 0.25-0.27 |
| 0.12 | 0.23-0.24 |
| 0.11 | 0.21-0.22 |
| 0.10 | 0.20      |
| 0.9  | 0.17-0.19 |
| 0.8  | 0.15-0.16 |
| 0.7  | 0.13-0.14 |
| 0.6  | 0.10-0.12 |
| 0.5  | 0.4-0.9   |
| 0.4  | 0.1-0.3   |