Learn how to create and manage multiple windows in your React GTK application, including modal dialogs and window lifecycle management.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/devhammed/react-gtk/llms.txt
Use this file to discover all available pages before exploring further.
Overview
React GTK allows you to render multipleGtkWindow components simultaneously. This is useful for:
- Creating dialog windows
- Building multi-window applications
- Showing modal popups
- Managing secondary application windows
Creating Multiple Windows
You can render multipleGtkWindow components by returning them as siblings in a React fragment:
Use React fragments (
<>...</>) to return multiple windows from your component without adding extra DOM nodes.Complete Example: Modal Dialog
Here’s a full example showing how to create a main window with a button that opens a modal dialog:Window Control Methods
Use refs to control window behavior programmatically:Window Properties
Modal Windows
Modal Windows
Set the Modal windows:
modal property to make a window modal:- Block interaction with other windows in the application
- Keep focus until closed
- Are ideal for dialogs and alerts that require user attention
Window Sizing
Window Sizing
Control window dimensions with:
defaultWidthanddefaultHeight: Initial window sizeresizable: Whether users can resize the window (default: true)
Window References
Window References
Use React refs to access window instances:The ref provides access to GTK window methods for programmatic control.
Best Practices
Window Lifecycle: By default, secondary windows may not be visible when first rendered. Use the
present() method to show them when needed, typically in response to user actions.Memory Management: Windows persist until explicitly closed. Make sure to provide users with a way to close secondary windows, either through a close button or the window’s close control.
Common Patterns
Conditional Window Rendering
You can conditionally render windows based on state:Window Communication
Use shared state to communicate between windows:Next Steps
- Explore form inputs for user input handling
- Learn about navigation within a single window
- Check out the GtkWindow component reference for all available properties
