https://github.com/samoylenkodmitry/cranpose
Cranpose is a Jetpack Compose-inspired declarative Rust UI framework. https://crates.io/crates/cranpose
https://github.com/samoylenkodmitry/cranpose
jetpack-compose rust ui-framework
Last synced: about 6 hours ago
JSON representation
Cranpose is a Jetpack Compose-inspired declarative Rust UI framework. https://crates.io/crates/cranpose
- Host: GitHub
- URL: https://github.com/samoylenkodmitry/cranpose
- Owner: samoylenkodmitry
- License: apache-2.0
- Created: 2025-10-08T07:46:35.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2026-06-02T10:15:59.000Z (9 days ago)
- Last Synced: 2026-06-02T12:14:12.673Z (9 days ago)
- Topics: jetpack-compose, rust, ui-framework
- Language: Rust
- Homepage: https://samoylenkodmitry.github.io/Cranpose
- Size: 15.8 MB
- Stars: 13
- Watchers: 0
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE-APACHE
- Code of conduct: CODE_OF_CONDUCT.md
- Agents: AGENTS.md
Awesome Lists containing this project
README
[https://codewiki.google/github.com/samoylenkodmitry/cranpose](https://codewiki.google/github.com/samoylenkodmitry/rs-compose)
[v0.0.40.webm](https://github.com/user-attachments/assets/df50209b-abfd-426a-b79c-a51a9543b385)
## 🌐 Live Demo
**[Try it in your browser!](https://samoylenkodmitry.github.io/Cranpose/)**
# Cranpose

Cranpose is a declarative UI framework for Rust, inspired by Jetpack Compose. It targets Desktop (Linux, macOS, Windows), Android, and Web (WASM) from a single Rust codebase. iOS is not a supported backend until a real UIKit/CAMetalLayer platform crate exists.
The composition runtime uses Slot Table V2: active groups live in preorder group, payload, and node tables, while inactive retained branches are explicit detached subtrees. Gap-table notes are historical rationale only; the active slot-table specification is [`docs/cranpose_slot_table_v2_design.md`](docs/cranpose_slot_table_v2_design.md).
## Quick Start via Isolated Demo
To get started, use the **Isolated Demo** template found in `apps/isolated-demo`. This project is pre-configured with the dependencies and build scripts for the implemented platforms.
```bash
# Clone the repository
git clone https://github.com/samoylenkodmitry/cranpose.git
cd cranpose/apps/isolated-demo
# Run on Desktop (Linux/macOS/Windows)
cargo run --features desktop,renderer-wgpu
```
## Example: Todo List Application
The following example demonstrates managing state, handling user input, and rendering a dynamic list.
```rust
use cranpose::prelude::*;
#[derive(Clone)]
struct TodoItem {
id: usize,
text: String,
done: bool,
}
#[composable]
fn TodoApp() {
// State management using useState
let items = useState(|| vec![
TodoItem { id: 0, text: "Buy milk".into(), done: false },
TodoItem { id: 1, text: "Walk the dog".into(), done: true },
]);
let input_text = useState(|| String::new());
let next_id = useState(|| 2);
Column(Modifier.fill_max_size().padding(20.0), || {
Text("My Todo List", Modifier.padding(10.0).font_size(24.0));
// Input Row
Row(Modifier.fill_max_width().padding(5.0), || {
BasicTextField(
value = input_text.value(),
on_value_change = move |new_text| input_text.set(new_text),
Modifier.weight(1.0).padding(5.0)
);
Button(
onClick = move || {
if !input_text.value().is_empty() {
let mut list = items.value();
list.push(TodoItem {
id: next_id.value(),
text: input_text.value(),
done: false,
});
items.set(list);
next_id.set(next_id.value() + 1);
input_text.set(String::new());
}
},
|| Text("Add")
);
});
// Dynamic List Rendering
LazyColumn(Modifier.weight(1.0), || {
items(items.value().len(), |i| {
let item = items.value()[i].clone();
Row(
Modifier
.fill_max_width()
.padding(5.0)
.clickable(move || {
// Toggle done status
let mut list = items.value();
if let Some(todo) = list.iter_mut().find(|t| t.id == item.id) {
todo.done = !todo.done;
}
items.set(list);
}),
|| {
Text(if item.done { "[x]" } else { "[ ]" });
Spacer(Modifier.width(10.0));
Text(
item.text,
Modifier.alpha(if item.done { 0.5 } else { 1.0 })
);
}
);
});
});
});
}
```
## Platform Support
| Platform | Backend | Status |
|---|---|---|
| Linux x86_64 | Vulkan via wgpu | Supported and actively tested |
| macOS aarch64 | Metal via wgpu | Experimental packaging; renderer path implemented |
| Windows x86_64 | DX12/Vulkan via wgpu | Experimental; not continuously tested |
| Android | Vulkan/GLES via wgpu | Experimental; release APK build is checked |
| iOS | UIKit/CAMetalLayer backend | Unavailable |
| Web (WASM) | WebGPU/WebGL2 via wgpu | Experimental; demo build is checked |
Release artifacts are available on the [Releases](https://github.com/samoylenkodmitry/Cranpose/releases) page for the platforms that have published builds.
## Building
The [`apps/isolated-demo`](apps/isolated-demo) starter project shows the complete cross-platform setup. It depends only on published crates from crates.io.
### Desktop (Linux/macOS/Windows)
```bash
cd apps/isolated-demo
cargo run --features desktop,renderer-wgpu
```
macOS `.app` bundles are built through the workspace task runner:
```bash
cargo xtask bundle-macos \
--package desktop-app \
--bin desktop-app \
--app-name "Cranpose Demo" \
--bundle-id io.cranpose.demo
```
Pass `--resources ` to copy bundle resources into `Contents/Resources`, and `--sign-identity ` to run the explicit codesign step.
### Android
```bash
# Prerequisites: cargo install cargo-ndk
cd apps/isolated-demo/android
./gradlew :app:assembleRelease
```
### iOS
iOS is unavailable. The `ios` cargo feature is reserved for the real platform backend and does not alias desktop.
### Web (WASM)
```bash
# Prerequisites: cargo install wasm-pack
cd apps/isolated-demo
./build-web.sh
python3 -m http.server 8080
```
## Verification Gates
The core workspace gates are:
```bash
cargo fmt --check
cargo test
cargo clippy
cargo build --workspace --no-default-features
cargo xtask dependency-budget
cargo xtask binary-size --package isolated-demo --bin isolated-demo --profile release-small --max-bytes 29360128
```
See [`apps/isolated-demo/README.md`](apps/isolated-demo/README.md) for full details.
## License
This project is available under the terms of the Apache License (Version 2.0). See [`LICENSE-APACHE`](LICENSE-APACHE) for the full license text.