A screen function turns a Store into an element tree. App owns the scene, layout and interaction state. The native host opens the operating-system window and forwards its events to that App.
Type::Headline and Theme::paper_dark() select theme tokens. The numbers passed to size are the initial logical size, not a promise about physical pixels on every display. Options::from_env() lets the existing host consume its normal diagnostic environment variables.
Complete example
Source: tutorial_hello_window.rs native/ui-host/examples/tutorial_hello_window.rs.
//! Run from native/: cargo run --locked -p aster-ui-host --example tutorial_hello_window
use aster_blueprint::ui::prelude::*;
use aster_native::{Options, RunWindow};
fn screen(_: &Store) -> El {
col([
text("Hello, Aster").style(Type::Headline),
text("Your first native window.").muted(),
]).gap(3).pad(6)
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = App::new(&Theme::paper_dark(), Store::new())
.size(640, 360).screen(screen)?;
if std::env::args().any(|a| a == "--headless") {
app.write_png("tutorial_hello_window.png")?;
return Ok(());
}
app.run_window_with(Options {
title: "Hello, Aster".into(), ..Options::default()
}.from_env())
}Run it
From the repository root:
cd native
cargo check --locked -p aster-ui-host --example tutorial_hello_window
cargo run --locked -p aster-ui-host --example tutorial_hello_windowWithout a desktop display, run the image-producing path instead:
cargo run --locked -p aster-ui-host --example tutorial_hello_window -- --headlessPNG files are written in the command's current directory. For the animation example, append --reduced-motion after -- to compare the reduced-motion policy.
What you will see
A dark window titled “Hello, Aster” contains a heading and a short sentence. Close the window to exit. No file is written in window mode.
Next steps
Change the heading, then try a different initial size. Continue with layout and text to build a more structured screen.