Overview
React GTK uses GTK’s native styling system rather than CSS. Widgets are styled through props that control appearance, layout, spacing, and alignment.Layout Fundamentals
Container Widgets
Layout is managed by container widgets likeGtkBox and GtkStackPage:
GtkBox- Linear container for horizontal or vertical layoutsGtkStackPage- Page container that extendsGtkBoxGtkWindow- Top-level container for windows
Orientation
Control layout direction with theorientation prop:
Spacing and Margins
Container Spacing
Set spacing between children in container widgets:Widget Margins
Control margins on individual widgets:Margin Properties
marginStart- Left margin (in LTR layouts)marginEnd- Right margin (in LTR layouts)marginTop- Top marginmarginBottom- Bottom margin
Alignment
Horizontal and Vertical Alignment
Control widget positioning within their allocated space:Alignment Options
Example: Centered Dialog Content
Widget Dimensions
Window Size
Set default window dimensions:Widget Size Requests
Override widget size requests:Expanding Widgets
Horizontal and Vertical Expansion
Control whether widgets expand to fill available space:Expansion Properties
hexpand- Expand horizontallyvexpand- Expand verticallyhexpandSet- Whether to usehexpandpropertyvexpandSet- Whether to usevexpandproperty
Homogeneous Layouts
Make all children the same size:Widget Appearance
Button Styling
Button Properties
hasFrame- Whether the button has a visible borderuseUnderline- Enable mnemonic underlinesiconName- Add an icon to the button
Entry Styling
Entry Properties
hasFrame- Whether to draw a borderplaceholderText- Placeholder text when emptymaxLength- Maximum text length
Text Styling with Pango
Style text using Pango attributes:Pango Attribute Types
foreground- Text colorweight- Font weight (bold, normal, etc.)size- Font sizestyle- Font style (italic, normal)underline- Underline style
Label Markup
Use Pango markup for rich text in labels:CSS Classes
Apply GTK CSS classes for theming:Common GTK CSS Classes
suggested-action- Highlighted action buttondestructive-action- Destructive action (usually red)flat- Flat button stylecircular- Circular buttonpill- Pill-shaped button
Visibility Control
Show or hide widgets:Opacity
Control widget transparency:Cursor
Change the cursor on hover:Cursor Values
Common cursor types:default,pointer,text,wait,crosshairhelp,move,grab,grabbingnot-allowed,no-dropn-resize,e-resize,s-resize,w-resizezoom-in,zoom-out
Sensitivity
Disable widget interaction:Focus Behavior
Focus Properties
canFocus- Widget or descendants can accept focusfocusable- Widget itself can accept focusfocusOnClick- Grab focus on mouse clickhasFocus- Whether widget has focus
Tooltips
Add helpful tooltips:Overflow Control
Transitions
Animate page transitions in stacks:Transition Types
Available inGtkStackTransitionType:
SLIDE_RIGHT/SLIDE_LEFTSLIDE_UP/SLIDE_DOWNCROSSFADEROTATE_LEFT/ROTATE_RIGHT
