A simple counter app built using the Yew crate in Rust. This application demonstrates the use of Yew and WebAssembly to create a web application with a button and counter.
To run the app, you need to install the WebAssembly target and Trunk:
- Add the WebAssembly target to your Rust installation:
rustup target add wasm32-unknown-unknown
- Install Trunk:
cargo install trunk
- In your
Cargo.tomlfile, add the Yew crate with version 0.20.0:
yew = { version = "0.20.0", features = ["csr"] }This app is built using the Yew framework. The core concept of Yew is the Component trait, which allows you to create reusable UI components with their own state and behavior. Components are updated based on incoming messages, allowing you to build complex applications with interactive features.
To run the app, use the following command:
trunk serve
This command generates the dist folder containing the necessary files and runs the app on localhost:8080.
To style the app, create a style.css file in the root directory. Include this file in your index.html by adding the following line:
<link data-trunk rel="css" href="style.css" />Make sure to include the data-trunk attribute to ensure that Trunk processes the link correctly.
Now you can add your custom styles to the style.css file, and they will be applied to the app.