WebUI
A simple Rust library for creating local web interfaces with real-time communication.
Features
- Easy to use - Simple API for creating web UIs for Rust applications
- Real-time communication - WebSocket support for instant updates
- HTTP fallback - REST API endpoint for broader compatibility
- Static file serving - Built-in server for HTML, CSS, and JavaScript files
- Event-driven - Register handlers for UI events with type safety
- Async/await support - Built on Tokio for high performance
Quick Start
Add this to your Cargo.toml:
[]
= "0.1"
= { = "1.0", = ["full"] }
Ensure that the webui.js file is included in your static files directory
Basic Example
use ;
async
HTML Setup
Create an index.html file in your static directory:
My Web UI
Click Me!
Configuration
let config = default
.with_port // Custom port
.with_title // Window title
.with_static_dir; // Static files directory
Event Handling
Simple Click Handler
web_ui.bind_click.await;
Event Handler with Response
web_ui.bind_event.await;
Examples
This repository includes several examples:
hello- Basic button click exampleevent_binding- Event handling with state managementwelcome- Welcome page exampletemplate- Template for creating new projects
Run examples with:
Project Structure
static/
├── index.html # Your main HTML file
├── style.css # Optional CSS styles
├── app.js # Your custom JavaScript
└── webui.js # WebUI client library (needed to bind events)