-
-
Notifications
You must be signed in to change notification settings - Fork 15
Overlay System
Blinc provides an overlay system for modals, dialogs, toasts, and context menus.
Overlays render on top of the main UI and handle their own lifecycle. Access the overlay manager through the context:
ctx.overlay_manager()Full-screen overlays with backdrop:
ctx.overlay_manager()
.modal()
.title("Confirm Action")
.content(|| {
div()
.flex_col()
.gap(16.0)
.child(text("Are you sure you want to proceed?"))
})
.show();ctx.overlay_manager()
.modal()
.title("Delete Item")
.content(|| {
text("This action cannot be undone.")
})
.primary_action("Delete", |_| {
delete_item();
})
.secondary_action("Cancel", |_| {
// Modal closes automatically
})
.show();Centered dialogs with customizable content:
ctx.overlay_manager()
.dialog()
.title("Settings")
.content(|| build_settings_form())
.primary_action("Save", |_| {
save_settings();
})
.secondary_action("Cancel", |_| {})
.show();ctx.overlay_manager()
.dialog()
.width(600.0)
.height(400.0)
.title("Large Dialog")
.content(|| content)
.show();Brief notifications:
// Simple toast
ctx.overlay_manager()
.toast("Item saved successfully!")
.show();
// With duration
ctx.overlay_manager()
.toast("Processing...")
.duration(5000) // 5 seconds
.show();
// Positioned
ctx.overlay_manager()
.toast("Copied to clipboard")
.position(ToastPosition::BottomCenter)
.show();ToastPosition::TopLeft
ToastPosition::TopCenter
ToastPosition::TopRight
ToastPosition::BottomLeft
ToastPosition::BottomCenter
ToastPosition::BottomRightRight-click menus:
div()
.on_context_menu(|evt| {
ctx.overlay_manager()
.context_menu()
.item("Copy", || copy_to_clipboard())
.item("Paste", || paste_from_clipboard())
.separator()
.item("Delete", || delete_selected())
.show_at(evt.mouse_x, evt.mouse_y);
})ctx.overlay_manager()
.context_menu()
.item("Edit", || {})
.submenu("Export", |menu| {
menu.item("PNG", || export_png())
.item("JPEG", || export_jpeg())
.item("SVG", || export_svg())
})
.show_at(x, y);Overlays close when:
- User clicks outside (backdrop click)
- Escape key is pressed
- Action callback completes
- Programmatically dismissed
let overlay_id = ctx.overlay_manager()
.modal()
.title("Loading...")
.content(|| spinner())
.show();
// Later, dismiss programmatically
ctx.overlay_manager().dismiss(overlay_id);For full control, use a custom overlay:
ctx.overlay_manager()
.custom(|| {
stack()
.w_full()
.h_full()
// Backdrop
.child(
div()
.w_full()
.h_full()
.bg(Color::rgba(0.0, 0.0, 0.0, 0.5))
)
// Content
.child(
div()
.absolute()
.inset(0.0)
.flex_center()
.child(my_custom_modal())
)
})
.show();-
Use appropriate overlay type - Modal for blocking actions, toast for notifications, dialog for forms.
-
Provide escape routes - Always include a way to close (cancel button, backdrop click).
-
Keep toasts brief - Short messages that don't require action.
-
Position context menus near cursor - Use event coordinates for natural placement.
-
Limit overlay nesting - Avoid opening overlays from within overlays.
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
- 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