-
Notifications
You must be signed in to change notification settings - Fork 9
Component Modal
MeowLynxSea edited this page Jun 1, 2026
·
7 revisions
A modal dialog panel shell.
This component only renders the dialog panel (title/content/actions). It does not implement overlay placement, focus trapping, or keyboard dismissal. Those behaviors live at the application layer.
- You already have an overlay (mask/layer management) at the app/widget layer, and you need a consistent-styled dialog panel.
- You want standardized slots: title / content / action row.
Not a good fit:
- You want the component to manage open/close, overlay, focus trapping, and Esc-to-dismiss.
Those are part of interaction lifecycle management and should live at the widget layer
(for example, a future
ModalLayer).
-
modal(): constructor -
title(...): optional title -
content(...): main content -
actions(...): optional action row -
width(px(...)): width (default:520px) -
closable(bool): show close button in header -
on_close(|window, cx| ...): callback when close button is clicked -
bg(...) / border(...): override theme colors
Related helpers:
-
modal_actions_row(direction, [...]): right-aligned button row (passcx.theme().text_directionfor RTL support) -
modal_primary_action("..."): primary button style (useful for confirm actions)
- Width:
520px - Background: theme-driven (
theme.surface.raisedby default)
use yororen_ui::component::{
button, modal, modal_actions_row,
};
use yororen_ui::theme::ActionVariantKind;
let view = modal()
.title("Delete server?")
.content("This action cannot be undone.")
.actions(modal_actions_row(
cx.theme().text_direction,
[
button().variant(ActionVariantKind::Neutral).child("Cancel").into_any_element(),
button().variant(ActionVariantKind::Danger).child("Delete").into_any_element(),
],
));use gpui::px;
use yororen_ui::component::{label, modal, modal_actions_row, button};
use yororen_ui::theme::ActionVariantKind;
let view = modal()
.width(px(640.))
.title("Advanced settings")
.content(
label("Put any layout here: forms, lists, explanatory text, etc.")
)
.actions(modal_actions_row(
cx.theme().text_direction,
[
button().variant(ActionVariantKind::Neutral).child("Close").into_any_element(),
button().variant(ActionVariantKind::Primary).child("Save").into_any_element(),
],
));use yororen_ui::component::{label, modal};
let view = modal()
.title("Settings")
.closable(true)
.on_close(|window, cx| {
// Handle close - e.g., hide the modal
})
.content(label("Modal content here"));Yororen UI v0.3.0 · repository · Apache-2.0 · This wiki documents Yororen UI v0.3.0.
This wiki documents Yororen UI v0.3.0 — the headless-core, swappable-renderer build.