GtkSwitch

A toggle switch widget.

Preview

CSS Node Tree

switch[:checked]
  ├── image (on icon)
  ├── image (off icon)
  └── slider

Props

Prop

Type

Behavior

  • Click or tap to toggle
  • Drag the slider horizontally to toggle
  • The active prop controls the user-facing state
  • The state prop can differ from active during async operations (e.g., connecting to WiFi)
  • onStateSet callback can return false to reject the change

Animation

The slider animates between positions with a 100ms ease-out-cubic transition, matching the native GTK behavior.

GTK4 Documentation →

On this page