| Crates.io | vizia |
| lib.rs | vizia |
| version | 0.3.0 |
| created_at | 2021-09-17 00:37:44.480887+00 |
| updated_at | 2025-04-16 15:49:35.873833+00 |
| description | A declarative desktop GUI framework |
| homepage | |
| repository | https://github.com/vizia/vizia |
| max_upload_size | |
| id | 452575 |
| size | 132,048 |

A simple counter application. Run with cargo run --example counter.
use vizia::prelude::*;
// Define some model data
#[derive(Lens)]
pub struct AppData {
count: i32,
}
// Define events to mutate the data
pub enum AppEvent {
Increment,
}
// Describe how the data is mutated in response to events
impl Model for AppData {
fn event(&mut self, _: &mut EventContext, event: &mut Event) {
event.map(|app_event, _| match app_event {
AppEvent::Increment => {
self.count += 1;
}
});
}
}
fn main() {
// Create an application
Application::new(|cx| {
// Build the model data into the tree
AppData { count: 0 }.build(cx);
// Declare views which make up the UI
HStack::new(cx, |cx| {
// Declare a button which emits an event
Button::new(cx, |cx| Label::new(cx, "Increment"))
.on_press(|cx| cx.emit(AppEvent::Increment));
// Declare a label which is bound to part of the model, updating when it changes
Label::new(cx, AppData::count).width(Pixels(50.0));
})
.alignment(Alignment::Center) // Apply style and layout modifiers
.horizontal_gap(Pixels(50.0));
})
.title("Counter") // Configure window properties
.inner_size((400, 100))
.run();
}

A quickstart guide for vizia is available here.
Auto-generated code documentation can be found here.
A list of examples is included in the repository.
To run an example with the winit (default) windowing backend:
cargo run --release --example name_of_example
To run an example with the baseview windowing backend:
cargo run --release --example name_of_example --no-default-features --features baseview
For help with vizia, or to get involved with contributing to the project, come join us on our discord.
Vizia is licensed under MIT.
Vizia logo designed by Lunae Somnia.