Repository navigation
Dialog
github-actions[bot] edited this page May 10, 2026
·
2 revisions
Dialogs display content in a modal overlay that requires user interaction.
use blinc_cn::prelude::*;
use blinc_core::use_state_keyed;
let is_open = use_state_keyed("dialog_open", || false);
dialog()
.open(is_open.clone())
.on_open_change({
let is_open = is_open.clone();
move |open| is_open.set(open)
})
.child(dialog_trigger()
.child(button("Open Dialog")))
.child(dialog_content()
.child(dialog_header()
.child(dialog_title("Dialog Title"))
.child(dialog_description("Dialog description")))
.child(text("Dialog content goes here."))
.child(dialog_footer()
.child(button("Close").on_click({
let is_open = is_open.clone();
move |_| is_open.set(false)
}))))The root component that manages open state.
dialog()
.open(is_open)
.on_open_change(|open| set_open(open))The element that opens the dialog when clicked.
dialog_trigger()
.child(button("Open"))The modal content container with backdrop.
dialog_content()
.child(/* dialog parts */)Contains title and description.
dialog_header()
.child(dialog_title("Title"))
.child(dialog_description("Description"))Contains action buttons.
dialog_footer()
.child(button("Cancel").variant(ButtonVariant::Outline))
.child(button("Confirm"))A button that closes the dialog.
dialog_close()
.child(button("Close"))For destructive or important confirmations:
let is_open = use_state_keyed("alert_dialog_open", || false);
alert_dialog()
.open(is_open.clone())
.on_open_change({
let is_open = is_open.clone();
move |open| is_open.set(open)
})
.child(alert_dialog_trigger()
.child(button("Delete").variant(ButtonVariant::Destructive)))
.child(alert_dialog_content()
.child(alert_dialog_header()
.child(alert_dialog_title("Are you sure?"))
.child(alert_dialog_description(
"This action cannot be undone."
)))
.child(alert_dialog_footer()
.child(alert_dialog_cancel().child(button("Cancel")))
.child(alert_dialog_action()
.child(button("Delete").variant(ButtonVariant::Destructive)))))A panel that slides in from the edge:
let is_open = use_state_keyed("sheet_open", || false);
sheet()
.open(is_open.clone())
.side(SheetSide::Right) // Left, Right, Top, Bottom
.on_open_change({
let is_open = is_open.clone();
move |open| is_open.set(open)
})
.child(sheet_trigger()
.child(button("Open Sheet")))
.child(sheet_content()
.child(sheet_header()
.child(sheet_title("Settings")))
.child(/* content */)
.child(sheet_footer()
.child(button("Save changes"))))A mobile-friendly bottom sheet:
let is_open = use_state_keyed("drawer_open", || false);
drawer()
.open(is_open.clone())
.on_open_change({
let is_open = is_open.clone();
move |open| is_open.set(open)
})
.child(drawer_trigger()
.child(button("Open Drawer")))
.child(drawer_content()
.child(drawer_header()
.child(drawer_title("Menu")))
.child(/* content */))let is_open = use_state_keyed("form_dialog_open", || false);
let name = use_state_keyed("form_dialog_name", || String::new());
let email = use_state_keyed("form_dialog_email", || String::new());
dialog()
.open(is_open.clone())
.on_open_change({
let is_open = is_open.clone();
move |open| is_open.set(open)
})
.child(dialog_trigger()
.child(button("Edit Profile")))
.child(dialog_content()
.child(dialog_header()
.child(dialog_title("Edit Profile"))
.child(dialog_description("Update your profile information")))
.child(
div()
.flex_col()
.gap(16.0)
.child(
div().flex_col().gap(4.0)
.child(label("Name"))
.child(input()
.value(&name)
.on_change({
let name = name.clone();
move |v| name.set(v)
}))
)
.child(
div().flex_col().gap(4.0)
.child(label("Email"))
.child(input()
.value(&email)
.on_change({
let email = email.clone();
move |v| email.set(v)
}))
)
)
.child(dialog_footer()
.child(dialog_close().child(
button("Cancel").variant(ButtonVariant::Outline)
))
.child(button("Save").on_click({
let is_open = is_open.clone();
move |_| {
save_profile();
is_open.set(false);
}
}))))let is_open = use_state_keyed("confirm_dialog_open", || false);
alert_dialog()
.open(is_open.clone())
.on_open_change({
let is_open = is_open.clone();
move |open| is_open.set(open)
})
.child(alert_dialog_trigger()
.child(button("Delete Account").variant(ButtonVariant::Destructive)))
.child(alert_dialog_content()
.child(alert_dialog_header()
.child(alert_dialog_title("Delete Account"))
.child(alert_dialog_description(
"Are you sure you want to delete your account? \
All your data will be permanently removed."
)))
.child(alert_dialog_footer()
.child(alert_dialog_cancel().child(
button("Cancel").variant(ButtonVariant::Outline)
))
.child(alert_dialog_action().child(
button("Delete")
.variant(ButtonVariant::Destructive)
.on_click(move |_| delete_account())
))))| Prop | Type | Default | Description |
|---|---|---|---|
open |
bool |
false |
Whether dialog is open |
on_open_change |
Fn(bool) |
- | Called when open state changes |
| Prop | Type | Default | Description |
|---|---|---|---|
open |
bool |
false |
Whether sheet is open |
side |
SheetSide |
Right |
Which side to slide from |
on_open_change |
Fn(bool) |
- | Called when open state changes |
enum SheetSide {
Left,
Right,
Top,
Bottom,
}Getting Started
Mobile Development
Example Gallery
- Example Gallery
- Canvas Element
- Canvas Kit Interactive
- Carousel Demo - Selector API Showcase
- Chrome-Style Tabs
- blinc_cn Components
- Code Element
- Complex SVG
- CSS Debug
- CSS Visual Features
- Layer Effects
- Emoji and HTML Entities
- @flow Shader
- Fluid Surface
- Skeleton animation with glTF +
blinc_canvas_kit. DrawContext::run_gpu_passend-to-end demo.- Image CSS Styling
- Image Layer Test
- Keyframe Animation Canvas
- Markdown Editor
- 3D Mesh Demo — renders the Khronos glTF
DamagedHelmetsample model - Motion Demo
- Music Player Glass Card
- Node-editor demo — pre-wired graph with three node types, typed
- Notch Menu Bar
- Overflow Fade
- Overlay System
- Pointer Query
- Rich Text Element
- Rich Text Editor
- Scroll Container
- Semantic @flow
- Sortable
- Stateful API + Signal-bound modifiers demo.
- End-to-end 3D demo wiring Blinc's SceneKit3D renderer up to
- Unified Styling API
- SVG Animation
- Table Builder
- Tabler Icons
- Minimal text positioning test
- Text Input Widgets
- KHR_texture_transform
- Theme System
- Timeline Animation
- Typography
- Video Player
- Wet Glass
- Windowed Application
Web Development
Core Concepts
- Elements & Layout
- Styling & Materials
- CSS Styling
- Theming
- Event Handling
- State Management
- Lists & Conditional Content
- Element Refs
Animation
Components
Component Library (blinc_cn)
Widgets
- Buttons & Inputs
- Text & Rich Text
- Code Editor
- Scroll Containers
- Virtualized List
- Canvas Drawing
- Images & SVG
- Audio & Video
- Markdown Rendering
Canvas Kit
Advanced
- Routing & Navigation
- Multi-Window
- System Integration
- Element Query API
- Overlay System
- Custom State Machines
- Pointer Query
- Performance Tips
- Flow Shaders
- 3D Rendering
- Custom GPU Passes
- Hot-reload (experimental)
Architecture
Contributing