| Crates.io | viewy-codegen |
| lib.rs | viewy-codegen |
| version | 2.0.6 |
| created_at | 2023-08-11 08:39:06.27+00 |
| updated_at | 2026-01-24 13:46:11.843178+00 |
| description | Procedural macros for Viewy web ui library. |
| homepage | |
| repository | https://github.com/strowbeary/viewy-rs |
| max_upload_size | |
| id | 941683 |
| size | 5,573 |
A web UI toolkit that combines the strengths of a design system with the ergonomics of a UI library. Build HTML pages from composable, strongly-typed Rust components and render either full pages (with head and assets) or just the content.
Status: beta (2.0.0-beta.4). Rust 1.87.0, edition 2024.
From crates.io:
cargo add viewy
Or add to Cargo.toml:
[dependencies]
viewy = "2"
Docs: https://docs.rs/viewy Repository: https://github.com/strowbeary/viewy-rs
The example below shows how to render a simple page using a minimal layout that wraps your content inside a container View.
use rocket::{get, launch, routes};
use rocket::response::content::RawHtml;
use viewy::{Page, RenderMode};
use viewy::components::{Text, TextStyle, View};
#[get("/")]
fn index() -> RawHtml<String> {
// Define a minimal layout: wrap content in a top-level View
let layout: viewy::Layout = Box::new(|content| {
let mut view = View::new();
// push the page content into the container
view.node.children.push(content);
view.render()
});
let html = Page::new(
"Hello World – Viewy",
layout,
Text::new("Hello, world!", TextStyle::LargeTitle),
)
.compile(RenderMode::Complete);
RawHtml(html)
}
#[launch]
fn rocket() -> rocket::Rocket<rocket::Build> {
rocket::build().mount("/", routes![index])
}
Viewy can inject styles and scripts into the generated page and supports light/dark themes. You can control global settings (favicons, base URL, etc.) via configuration loaded by viewy::Config. See the crate docs for details.
This repository is a Cargo workspace:
MIT © Rémi Caillot