Skip to content
Proyectos

Acerca de

Componentes e interfaces de usuario reutilizables creados sobre gpui.

Desarrollo web y de aplicaciones

Cómo se miden estas cifras

What you can do

  • 58 components - Buttons, inputs, badges, tooltips, modals, popovers, selects, lists, virtualised lists, trees, tables, and more
  • Three-layer architecture - Headless primitives + JSON themes + swappable visual renderers (default + winui)
  • JSON themes - Swap palettes at runtime with one install() call
  • Animation system - AnimatedVisibility on every stateful composite, plus presets and easing functions

Crecimiento de estrellas medido

in 24h
0
in 7 days
-1
in 15 days
+1
in 1 month
Recopilando historial

Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.

README.md

Original

Yororen UI

中文版 · English

License Rust Edition Powered by gpui Version

Yororen UI is a headless-first Rust UI library built on top of gpui (via gpui-ce). A button is not a visual — it is a focusable, clickable thing with a label and an optional icon. The visual is a plug-in.

theme JSON  ─▶  renderer (XxxRenderer)  ─▶  headless (XxxProps)  ─▶  gpui-ce
  • Headless (yororen-ui-core) — data, state, a11y, i18n, RTL, animation, assets. No visual decisions.
  • Renderer (yororen-ui-default-renderer · yororen-ui-winui-renderer) — turns props into a styled div. 58 trait slots, filled with Token* or WinUI* impls. Swap the renderer, change the entire look.
  • Theme — a JSON file. The renderer reads paths like action.primary.bg; missing paths fall back to renderer defaults.

The meta-crate yororen-ui re-exports core + the default renderer + three bundled locales, so most apps need a single dependency. Add the winui or xml feature to opt into the alternative renderer or the XML DSL.


Features

Capability What you get
58 components Buttons, inputs, badges, tooltips, modals, popovers, selects, lists, virtualised lists, trees, tables, and more
Three-layer architecture Headless primitives + JSON themes + swappable visual renderers (default + winui)
JSON themes Swap palettes at runtime with one install() call
Animation system AnimatedVisibility on every stateful composite, plus presets and easing functions
Internationalization en, zh-CN, ar bundled; ar flips layout to RTL via cx.i18n().text_direction()
Accessibility Focus management, keyboard navigation, click-outside guards, scroll-lock counter, focus trap
Embedded assets 20+ SVG icons bundled via rust-embed
Notification system NotificationCenter global with auto-dismiss timers, sticky flag, and persistence
Optional XML DSL Declarative screens via xml! / xml_file! macros

Quick start

use gpui::{App, AppContext, Bounds, WindowBounds, WindowOptions, px, size};
use yororen_ui::assets::UiAsset;
use yororen_ui::locale_en;
use yororen_ui::renderer;

fn main() {
    let app = gpui_ce_platform::application().with_assets(UiAsset);

    app.run(|cx: &mut App| {
        cx.spawn(async |cx| cx.update(open_window)).detach();
    });
}

fn open_window(cx: &mut App) {
    // 1) Renderer + theme — picks system-light or system-dark by OS appearance,
    //    installs the global Theme, and registers 58 default XxxRenderer impls.
    renderer::install(cx, cx.window_appearance());

    // 2) Text-input keymap (idempotent).
    yororen_ui::headless::text_input::init(cx);

    // 3) Locale.
    locale_en::install(cx);

    // 4) Main window.
    let options = WindowOptions {
        window_bounds: Some(WindowBounds::Windowed(
            Bounds::centered(None, size(px(800.), px(600.)), cx),
        )),
        ..Default::default()
    };
    cx.open_window(options, |_, cx| cx.new(|_| my_app::MyApp))
        .expect("failed to open main window");
    cx.activate(true);
}

With gpui-ce 0.3.0 on macOS, schedule window setup with App::spawn as shown: the native launch callback holds a platform lock that open_window also needs. The foreground task runs after that callback returns.

Inside your Render::render:

use yororen_ui::headless::button::button;
use yororen_ui::headless::label::label;

fn render(&mut self, _w: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
    div().size_full().flex().items_center().justify_center().gap_2()
        .child(label("count", "0", cx).render(cx))
        .child(button("inc", cx).caption("+").render(cx))
}

Every headless factory exposes both .apply(div) (a11y only) and .render(cx) (full visual via the registered renderer). For text inputs, .render(cx, window) is two-arg and registers an IME handler.

Swap renderers or themes (optional)

WinUI renderer

use yororen_ui::winui_renderer;

winui_renderer::install_with(cx, winui_renderer::themes::winui_light());

Custom JSON theme

use yororen_ui_default_renderer::{Theme, install_with};

const MY_THEME: &str = include_str!("../themes/my-brand.json");
install_with(cx, Theme::from_json(MY_THEME).expect("valid JSON"));

Live theme switching

Call yororen_ui::theme::install(cx, new_theme) inside a Render impl — every frame, or when the user picks a new palette. Idempotent and cheap.

impl Render for MyApp {
    fn render(&mut self, _w: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
        yororen_ui::theme::install(cx, self.current_theme());
        // … rest of render …
    }
}

Demos

counter — minimal bootstrap, single Entity<T> global, three buttons.

Counter demo

cargo run -p counter-demo

gallery_demo — kitchen-sink reference: every component, theme switching, i18n, notifications, virtualised list.

Gallery demo

cargo run -p gallery-demo

inputs_demo — all seven text inputs wired with cx.entity().clone(). Handles Tab / Enter / Esc / ⌘V.

Inputs demo

cargo run -p inputs-demo

layers_demo — the three render pathways side by side + a hand-rolled Material ripple.

Layers demo

cargo run -p layers-demo

theme_showcase — live theme switching via theme::install per render. Cycles four themes.

Theme showcase demo

cargo run -p theme-showcase-demo

variant_showcase — ActionVariantKind comparison (Neutral / Primary / Danger) with the same headless::button factory.

Variant showcase demo

cargo run -p variant-showcase-demo

gallery_xml — the gallery written with the XML DSL instead of the Rust builder API.

Gallery XML demo

cargo run -p gallery-xml-demo

showcase_xml — smaller XML-DSL smoke test.

Showcase XML demo

cargo run -p showcase-xml-demo

What's inside

Crate Role
yororen-ui-core Headless primitives, theme JSON access, i18n, a11y, RTL, animation, assets, notification center
yororen-ui-default-renderer 58 TokenXxxRenderer impls + bundled system-light.json / system-dark.json themes + renderer::install bootstrap
yororen-ui-winui-renderer
(optional, feature winui)
WinUI-style palette, compact controls, accent focus rings, subtle borders
yororen-ui-xml + yororen-ui-xml-macro
(optional, feature xml, default-on)
XML DSL: xml!, xml_file!, register_xml_component!, bind
yororen-ui-locale-{en, zh-CN, ar} Bundled JSON translation catalogs
yororen-ui
(meta-crate)
Re-exports the above. Most apps need only this.

Three-layer architecture

theme JSON  ─▶  renderer (XxxRenderer)  ─▶  headless (XxxProps)  ─▶  gpui-ce
  • Headless — data + control + a11y. No visual.
  • Renderer — a per-component trait that reads the theme and produces visual divs.
  • Theme — a single serde_json::Value you can swap at runtime.

The 58 component markers (yororen-ui-core::renderer::markers) are the keys into the global RendererRegistry. The default and WinUI renderers each implement all 58 trait slots.

A custom renderer only needs to implement the 58 XxxRenderer traits — it doesn't touch the headless layer.


Installation

From crates.io (recommended)
[dependencies]
yororen_ui = "0.4"

The xml feature is enabled by default so xml! / xml_file! work out of the box. To opt out:

[dependencies]
yororen_ui = { version = "0.4", default-features = false }

To enable specific features:

[dependencies]
yororen_ui = { version = "0.4", default-features = false, features = ["xml", "winui"] }
From GitHub (latest development build)
[dependencies]
yororen_ui = { git = "https://github.com/MeowLynxSea/yororen-ui.git", tag = "v0.4.0" }
From a local path (development)
[dependencies]
yororen_ui = { path = "../yororen-ui/crates/yororen-ui" }
gpui dependency

gpui is provided via the gpui-ce crate on crates.io. Make sure your application uses a compatible version:

[dependencies]
gpui = { package = "gpui-ce", version = "0.3.0" }
gpui-ce-platform = { package = "gpui_ce_platform", version = "0.3.0", features = ["font-kit", "wayland", "x11"] }

In this repository, gpui-ce is specified in Cargo.toml.


Requirements

  • Rust: 1.95 or later (edition 2024)
  • GPUI: the October 2026 gpui-ce 0.3.0 release line; use gpui_ce_platform 0.3.0 for app startup. The older 0.3.2/0.3.3 releases are yanked and incompatible.
  • Migration: Yororen UI 0.4 uses this GPUI line throughout; upgrade all Yororen crates together from 0.3. No git patches are needed.
  • Release status: this branch prepares 0.4.0; the 0.4 registry and tag examples apply after that release is published.
  • Platforms: macOS, Linux, Windows (whatever gpui-ce supports)

License

Licensed under the Apache License, Version 2.0. Built on top of gpui (Zed Industries), also Apache-2.0. See LICENSE and NOTICE for attribution.


Contributing

Issues and PRs are welcome. When changing visuals:

  • Include screenshots or a short recording
  • Keep changes rustfmt-clean

Wiki

See the Yororen UI Wiki for guides, recipes, and per-component references.


Star History


Maintained by Yoro.ren

Yororen — Maintained with care

Explorar proyectos relacionados

Cargando…