rinch
The main rinch crate provides the application entry point, shell runtime, and re-exports commonly used types from rinch-core, rinch-macros, rinch-theme, and rinch-components.
Entry Point
rinch::run
Runs a rinch application with the given root component:
use rinch::prelude::*;
#[component]
fn app() -> NodeHandle {
rsx! {
div {
h1 { "Hello, rinch!" }
p { "A lightweight GUI framework for Rust." }
}
}
}
fn main() {
run("My App", 800, 600, app);
}
rinch::run_with_theme
Runs with a theme configuration:
use rinch::prelude::*;
fn main() {
let theme = ThemeProviderProps {
primary_color: Some("cyan".into()),
default_radius: Some("md".into()),
..Default::default()
};
run_with_theme("Themed App", 800, 600, app, theme);
}
rinch::run_with_window_props
Runs with full window configuration:
use rinch::prelude::*;
fn main() {
let props = WindowProps {
title: "My App".into(),
width: 1024,
height: 768,
borderless: true,
transparent: true,
..Default::default()
};
run_with_window_props(app, props, None);
}
Prelude
Import commonly used types with the prelude:
#![allow(unused)]
fn main() {
use rinch::prelude::*;
}
This includes:
Entry points (desktop feature):
run,run_with_theme
Element and prop types (from rinch_core::element::*):
Element,Children,WindowProps,ThemeProviderPropsCallback,SectionRenderer
Menu types (from rinch::menu):
Menu,MenuItem— unified builder API for native menus and tray menus
Reactive primitives:
Signal,Effect,Memo,Scopebatch,derived,untracked
Hooks:
Signal::new,Memo::new,Effect::newcreate_context,use_context,try_use_context
DOM construction:
NodeHandle,RenderScope,with_render_scope
Component trait:
Component
Control flow:
show_dom,FineShowBuilder(conditional rendering)for_each_dom,ForItem,FineForBuilder(list rendering)
Event handling:
ClickContext,InputCallback,get_click_context,start_drag
Icons:
Icon
Macros:
rsx!,#[component]
Window controls (desktop feature):
close_current_window,minimize_current_window,toggle_maximize_current_window
Theme types (theme feature):
- All types from
rinch_theme(colors, spacing, radius, etc.)
Component types (components feature):
- All component structs from
rinch_components(Button, TextInput, Stack, Group, etc.)
Macros
#![allow(unused)]
fn main() {
pub use rinch_macros::rsx; // RSX macro for DOM construction
pub use rinch_macros::component; // #[component] attribute macro
}
Re-exports
Element Types
#![allow(unused)]
fn main() {
pub use rinch_core::element::{
Children,
Element,
ThemeProviderProps,
WindowProps,
};
}
Reactive Primitives
#![allow(unused)]
fn main() {
pub use rinch_core::{
batch,
derived,
untracked,
Effect,
Memo,
Scope,
Signal,
};
}
Sub-crates
#![allow(unused)]
fn main() {
pub use rinch_core as core;
pub use rinch_renderer as renderer; // desktop feature
}
Modules
rinch::shell
Application runtime and event loop:
run()- Entry point functionrun_with_theme()- Entry point with theme configurationrun_with_menu()- Entry point with native menu barrun_with_window_props()- Entry point with full window propsrun_with_window_props_and_menu()- Entry point with full window props and menurun_rinch(),run_rinch_with_window_props()- Lower-level runtime entry points (deprecated)
rinch::menu
Unified menu builder API for native menus and tray context menus:
Menu- Builder with.item(),.separator(),.submenu()methodsMenuItem- Builder with.shortcut(),.enabled(),.on_click()methods
rinch::window
Window utilities (currently minimal, window management is in shell).
rinch::windows
Window control functions for custom window chrome:
close_current_window()minimize_current_window()toggle_maximize_current_window()
rinch::fine_grained
Fine-grained rendering types (re-exported from rinch-core):
NodeHandle,RenderScope
rinch::theme (theme feature)
Theme system types from rinch-theme.
rinch::components (components feature)
Component library from rinch-components.
rinch::dialogs (file-dialogs feature)
File dialog wrappers via rfd.
rinch::clipboard (clipboard feature)
Clipboard operations.
rinch::tray (system-tray feature)
System tray support.