Expand description
Modal container widget (overlay layer), dialog presets, modal stack management, and animations.
§Animation System (bd-39vx.4)
Modals support smooth entrance and exit animations:
- Scale-in/out: Classic modal pop effect
- Fade-in/out: Opacity transition
- Slide animations: Slide from top/bottom
- Backdrop fade: Independent backdrop opacity animation
- Reduced motion: Respects accessibility preferences
Use ModalAnimationState to track animation progress and compute
interpolated values for scale, opacity, and position.
§Focus Management (bd-39vx.5)
Modals can integrate with crate::focus::FocusManager for accessibility:
- Auto-focus: First focusable element receives focus when modal opens
- Focus trap: Tab navigation is constrained within the modal
- Focus restore: Previous focus is restored when modal closes
- Escape to close: Already built into modal handling
Use FocusAwareModalStack for automatic focus management, or integrate
manually using ModalStack::push_with_focus with your own FocusManager.
§Example
ⓘ
use ftui_widgets::modal::{FocusAwareModalStack, WidgetModalEntry, ModalAnimationState};
let mut modals = FocusAwareModalStack::new();
let mut animation = ModalAnimationState::new();
// Start opening animation
animation.start_opening();
// Push modal with focus trap
modals.push_with_trap(
Box::new(WidgetModalEntry::new(dialog).with_focusable_ids(vec![1, 2, 3])),
vec![1, 2, 3],
);Re-exports§
pub use focus_integration::FocusAwareModalStack;
Modules§
- focus_
integration - Focus-aware modal integration for automatic focus trap management.
Structs§
- Backdrop
Config - Backdrop configuration (color + opacity).
- Dialog
- A dialog widget built on Modal.
- Dialog
Builder - Builder for custom dialogs.
- Dialog
Button - A button in a dialog.
- Dialog
Config - Dialog configuration.
- Dialog
State - Dialog state for handling input and button focus.
- Modal
- Modal container widget.
- Modal
Animation Config - Animation configuration for modals.
- Modal
Animation State - Current animation state for a modal.
- Modal
Config - Modal configuration.
- Modal
Focus Integration - Helper for integrating
ModalStackwithFocusManager. - ModalId
- Unique identifier for a modal in the stack.
- Modal
Result - Result returned when a modal is closed.
- Modal
Size Constraints - Modal size constraints (min/max width/height).
- Modal
Stack - Stack of active modals with z-ordering and input routing.
- Modal
State - Stateful helper for modal close behavior.
- Widget
Modal Entry - A simple modal entry that wraps any Widget.
Enums§
- Dialog
Kind - Dialog type variants.
- Dialog
Result - Result from a dialog interaction.
- Modal
Action - Modal action emitted by
ModalState::handle_event. - Modal
Animation Phase - Current phase of the modal animation lifecycle.
- Modal
Easing - Easing function for modal animations.
- Modal
Entrance Animation - Entrance animation type for modal content.
- Modal
Exit Animation - Exit animation type for modal content.
- Modal
Position - Modal positioning options.
- Modal
Result Data - Modal result data variants.
Constants§
- DIALOG_
HIT_ BUTTON - Hit region for dialog buttons.
- MODAL_
HIT_ BACKDROP - Hit region tag for the modal backdrop.
- MODAL_
HIT_ CONTENT - Hit region tag for the modal content.
Traits§
- Stack
Modal - Trait for modal content that can be managed in the stack.
Type Aliases§
- Modal
Focus Id - A FocusId alias for modal focus management.