std.ui — Material Design 3 UI Toolkit & Hardware GPU Motion
Cross-platform high-refresh GDI/Skia UI engine featuring Google Material Design 3 tokens, elevation shadow system, interactive widgets, and 120 FPS GPU motion physics.
Module Namespace:
import std.ui
Overview
The std.ui library delivers a complete design system for desktop, mobile (Android/iOS), and browser WebAssembly runtimes. It includes Material Design 3 color roles, typography scales, 6-level elevation shadows, and 10+ reactive widgets.
Component Primitives
| Widget / Feature | Description |
|---|---|
fn draw_button(...) | Renders Filled, Tonal, Outlined, Text, and Elevated MD3 buttons with ripple state feedback. |
fn draw_card(...) | Renders Elevated, Filled, and Outlined cards with dynamic elevation shadows (Level 0 - Level 5). |
fn draw_text_field(...) | Interactive input field supporting cursor tracking, placeholder text, and active focus state. |
fn draw_slider(...) | Interactive continuous slider with visual thumb position and hit testing. |
fn draw_switch(...) | Toggle switch component with smooth motion track transitions. |
fn draw_progress_bar(...) | Determinate/indeterminate progress bar indicators. |
fn poll_input() -> InputState | Queries real-time native OS mouse coordinates, click state, hit testing, and key events. |
struct AnimationController | Hardware GPU 120 FPS motion clock with cubic emphasized decelerate easing curves. |
Code Example
import std.ui
fn main() {
let mut win = ui.Window::new("Nyx Material Design Studio", 1024, 768)
let mut controller = ui.AnimationController::new(300.0) // 300ms easing
controller.forward()
while win.is_open() {
let input = ui.poll_input()
let t = controller.value() // Current eased animation ratio 0.0 -> 1.0
ui.begin_frame()
ui.draw_rect(0.0, 0.0, 1024.0, 768.0, ui.COLOR_SURFACE)
ui.draw_button(50.0, 50.0, 160.0, 48.0, "Click Me", ui.BUTTON_FILLED, input)
ui.draw_card(50.0, 120.0, 300.0, 200.0, "Card Header", 3, t) // Elevation level 3
ui.end_frame()
}
}