- 100+个 Material 3 Expressive 组件
- 6个平台,同一份代码
- 0无变化时的重绘
- 100%Rust,没有 WebView
use tessera_components::{
alignment::{CrossAxisAlignment, MainAxisAlignment},
button::button,
column::column,
modifier::ModifierExt as _,
surface::surface,
text::text,
theme::material_theme,
};
use tessera_ui::{Dp, Modifier, remember, tessera};
#[tessera]
pub fn app() {
let count = remember(|| 0i32);
material_theme().child(move || {
surface()
.modifier(Modifier::new().fill_max_size())
.child(move || {
column()
.modifier(Modifier::new().fill_max_size())
.main_axis_alignment(MainAxisAlignment::Center)
.cross_axis_alignment(CrossAxisAlignment::Center)
.children(move || {
text(count.get().to_string()).size(Dp(40.0));
button()
.filled()
.on_click(move || count.with_mut(|c| *c += 1))
.child(|| text("Increment"));
});
});
});
}工作方式
界面是关于状态的 Rust 函数。Tessera 按需执行它们来构建每帧,并通过 GPU 在 Vulkan、Metal、DirectX 12 或 WebGPU 上绘制。没有 HTML,没有 CSS,没有 WebView。
创建项目
$ cargo install cargo-tessera
$ cargo tessera new my-app
$ cd my-app && cargo tessera dev
跨平台支持
支持 Windows、macOS、Linux、Android、iOS 和 Web。
自定义着色器
用插件式着色器编写一切效果,内置组件库也不例外。
现代的脚手架
仅需 cargo-tessera 便可完成一切操作。
纯粹的 Rust
纯粹的 Rust 语法,0% RSX。