百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
Y

yororen-ui

> 编程语言
开源

基于 gpui 构建的可重复使用的 UI 组件和小组件。

342 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

基于 gpui 构建的可重复使用的 UI 组件和小组件。

Yororen UI

中文版 · English

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-brutalism-renderer) — turns props into a styled div. 55 trait slots, filled with Token* or Brutal* 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 brutalism or xml feature to opt into the alternative renderer or the XML DSL.


Features

Capability
What you get




55 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 + brutalism)




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

…

Inside your Render::render:

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

fn render(&mut self, _w: &mut Window, cx: &mut Context) -> 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)

Brutalism renderer

rust
use yororen_ui::brutalism_renderer;

brutalism_renderer::install(cx);   // sharp corners, hard shadows, monospace

Custom JSON theme

rust
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.

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

Demos

counter — minimal bootstrap, single Entity global, three buttons.

cargo run -p counter-demo

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

cargo run -p gallery-demo

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

cargo run -p inputs-demo

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

cargo run -p layers-demo

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

cargo run -p theme-showcase-demo

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

cargo run -p variant-showcase-demo

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

cargo run -p gallery-xml-demo

showcase_xml — smaller XML-DSL smoke test.

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
55 TokenXxxRenderer impls + bundled system-light.json / system-dark.json themes + renderer::install bootstrap




yororen-ui-brutalism-renderer

(optional, feature brutalism) Sharp corners, thick black borders, hard offset shadows, monospace typography

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 55 component markers (yororen-ui-core::renderer::markers) are the keys into the global RendererRegistry. The default and brutalism renderers each implement all 55 trait slots.

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


Installation

From crates.io (recommended)

toml
[dependencies]
yororen_ui = "0.3"

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

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

To enable specific features:

toml
[dependencies]
yororen_ui = { version = "0.3", default-features = false, features = ["xml", "brutalism"] }

From GitHub (latest development build)

toml
[dependencies]
yororen_ui = { git = "https://github.com/MeowLynxSea/yororen-ui.git", tag = "v0.3.0" }

From a local path (development)

toml
[dependencies]
yororen_ui = { path = "../yororen-ui" }

gpui dependency

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

toml
[dependencies]
gpui = { package = "gpui-ce", version = "0.3" }

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


Requirements

  • Rust edition: 2024
  • 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

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rust

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言