---
name: developing-gtkx-apps
description: Build GTK4 desktop applications with GTKX React framework. Use when creating GTKX components, working with GTK widgets, handling signals, or building Linux desktop UIs with React.
---
# Developing GTKX Applications
GTKX is a React framework for building native GTK4 desktop applications on Linux. It uses a custom React reconciler to render React components as native GTK widgets.
## Quick Start
```tsx
import { ApplicationWindow, render, quit } from "@gtkx/react";
import * as Gtk from "@gtkx/ffi/gtk";
const App = () => (
);
render(, "com.example.myapp");
```
## Widget Patterns
### Container Widgets
**Box** - Linear layout:
```tsx
```
**Grid** - 2D positioning:
```tsx
```
**Stack** - Page-based container:
```tsx
```
**Notebook** - Tabbed container:
```tsx
```
**Paned** - Resizable split:
```tsx
```
### Virtual Scrolling Lists
**ListView** - High-performance scrollable list with selection:
```tsx
setSelectedId(ids[0])}
renderItem={(item: Item | null) => (
)}
>
{items.map(item => (
))}
```
**GridView** - Grid-based virtual scrolling:
```tsx
(
)}
>
{items.map(item => (
))}
```
**ColumnView** - Table with sortable columns:
```tsx
(
)}
/>
{items.map(item => (
))}
```
**DropDown** - String selection widget:
```tsx
{options.map(opt => (
))}
```
### HeaderBar
Pack widgets at start and end of the title bar:
```tsx
```
### ActionBar
Bottom bar with packed widgets:
```tsx
```
### Controlled Input
Entry requires two-way binding:
```tsx
const [text, setText] = useState("");
setText(entry.getText())}
placeholder="Type here..."
/>
```
### Declarative Menus
```tsx
```
## Signal Handling
GTK signals map to `on` props:
- `clicked` → `onClicked`
- `toggled` → `onToggled`
- `changed` → `onChanged`
- `notify::selected` → `onNotifySelected`
## Widget References
```tsx
import { useRef } from "react";
const entryRef = useRef(null);
// Later: entryRef.current?.getText()
```
## Portals
```tsx
import { createPortal } from "@gtkx/react";
{createPortal()}
```
## Constraints
- **GTK is single-threaded**: All widget operations on main thread
- **Virtual lists need immutable data**: Use stable object references
- **ToggleButton auto-prevents feedback loops**: Safe for controlled state
- **Entry needs two-way binding**: Use `onChanged` to sync state
For detailed widget reference, see [WIDGETS.md](WIDGETS.md).
For code examples, see [EXAMPLES.md](EXAMPLES.md).