Skip to content

Builtin Intrinsic Elements

These are just Gtk widgets which can be used without explicitly importing. For example <box /> and <Gtk.Box /> are exactly the same thing.

Gtk4

box

Gtk.Box

tsx
<box orientation={Gtk.Orientation.HORIZONTAL}>
  <Child />
  <Child />
  <Child />
</box>

button

Gtk.Button

tsx
<button onClicked={() => print("clicked")}>
  <Child />
</button>

centerbox

Gtk.CenterBox

tsx
<centerbox orientation={Gtk.Orientation.HORIZONTAL}>
  <Child $type="start" />
  <Child $type="center" />
  <Child $type="end" />
</centerbox>

drawingarea

Gtk.DrawingArea

tsx
<drawingarea
  $={(self) =>
    self.set_draw_func((area, cr, width, height) => {
      //
    })
  }
/>

entry

Gtk.Entry

tsx
<entry
  placeholderText="Start typing..."
  text=""
  onNotifyText={({ text }) => print(text)}
/>

image

Gtk.Image

tsx
<image
  file="/path/to/file.png"
  iconName="system-search-symbolic"
  pixelSize={16}
/>

label

Gtk.Label

tsx
<label
  label="<span foreground='blue'>text</span>"
  useMarkup
  wrap
  ellipsize={Pango.EllipsizeMode.END}
/>

levelbar

Gtk.LevelBar

tsx
<levelbar
  orientation={Gtk.Orientation.HORIZONTAL}
  widthRequest={200}
  value={0.5}
/>

Gtk.MenuButton

tsx
<menubutton>
  button content
  <popover>popover content</popover>
</menubutton>

overlay

Gtk.Overlay

tsx
<overlay>
  <Child />
  <Child $type="overlay" />
  <Child $type="overlay" />
</overlay>

revealer

Gtk.Revealer

tsx
<revealer
  transitionType={Gtk.RevealerTransitionType.SLIDE_RIGHT}
  revealChild={true}
  onNotifyChildRevealed={() => print("animation finished")}
>
  <Child />
</revealer>

scrolledwindow

Gtk.ScrolledWindow

tsx
<scrolledwindow maxContentHeight={500}>
  <Child />
</scrolledwindow>

slider

Astal.Slider

tsx
<slider
  value={0.5}
  min={0}
  max={1}
  onChangeValue={({ value }) => print(value)}
/>

stack

Gtk.Stack

tsx
<stack $={(self) => (self.visibleChildName = "child2")}>
  <Child $type="named" name="child1" />
  <Child $type="named" name="child2" />
</stack>

switch

Gtk.Switch

tsx
<switch active={true} onNotifyActive={({ active }) => print(active)} />

togglebutton

Gtk.ToggleButton

tsx
<togglebutton active={true} onToggled={({ active }) => print(active)} />

window

Astal.Window

tsx
<window
  visible
  namespace="bar"
  class="Bar"
  monitor={0}
  exclusivity={Astal.Exclusivity.EXCLUSIVE}
  keymode={Astal.Keymode.ON_DEMAND}
  anchor={
    Astal.WindowAnchor.TOP | Astal.WindowAnchor.LEFT | Astal.WindowAnchor.RIGHT
  }
/>

Gtk3

box

Gtk.Box

tsx
<box orientation={Gtk.Orientation.HORIZONTAL}>
  <Child />
  <Child />
  <Child />
</box>

button

Gtk.Button

tsx
<button onClicked={() => print("clicked")}>
  <Child />
</button>

centerbox

Astal.CenterBox

tsx
<centerbox orientation={Gtk.Orientation.HORIZONTAL}>
  <Child $type="start" />
  <Child $type="center" />
  <Child $type="end" />
</centerbox>

circularprogress

Astal.CircularProgress

tsx
<circularprogress value={0.5} startAt={0.75} endAt={0.75}>
  <icon />
</circularprogress>
css
circularprogress {
  color: green;
  background-color: black;
  font-size: 6px;
  margin: 2px;
  min-width: 32px;
}

drawingarea

Gtk.DrawingArea

tsx
<drawingarea
  onDraw={(self, cr) => {
    //
  }}
/>

entry

Gtk.Entry

tsx
<entry
  onChanged={({ text }) => print("text changed", text)}
  onActivate={({ text }) => print("enter", text)}
/>

eventbox

Astal.EventBox

tsx
<eventbox
  onClick={(_, event) => {
    print(event.modifier, event.button)
  }}
/>

icon

Astal.Icon

tsx
<icon
  // named icon or path to a file
  icon="/path/to/file.png"
  icon="missing-symbolic"
/>
css
icon {
  font-size: 16px;
}

label

Astal.Label

tsx
<label label="hello" maxWidthChars={16} wrap />

levelbar

Astal.LevelBar

tsx
<levelbar value={0.5} widthRequest={200} />

overlay

Astal.Overlay

tsx
<overlay>
  <Child>child</Child>
  <Child>overlay 1</Child>
</overlay>

revealer

Gtk.Revealer

tsx
<revealer
  transitionType={Gtk.RevealerTransitionType.SLIDE_RIGHT}
  revealChild={true}
  onNotifyChildRevealed={() => print("animation finished")}
>
  <Child />
</revealer>

scrollable

Astal.Scrollable

tsx
<scrollable heightRequest={100}>
  <Child />
</scrollable>

slider

Astal.Slider

tsx
<slider widthRequest={100} onDragged={({ value }) => print(value)} />

stack

Astal.Stack

tsx
<stack $={(self) => (self.visibleChildName = "child2")}>
  <Child name="child1" />
  <Child name="child2" />
</stack>

switch

Gtk.Switch

tsx
<switch active={true} onNotifyActive={({ active }) => print(active)} />

overlay

Astal.Overlay

tsx
<overlay>
  <Child>child</Child>
  <Child>overlay 1</Child>
  <Child>overlay 1</Child>
</overlay>

togglebutton

Gtk.ToggleButton

tsx
<togglebutton active={true} onToggled={({ active }) => print(active)} />

window

Astal.Window

tsx
<window
  visible
  namespace="bar"
  class="Bar"
  monitor={0}
  exclusivity={Astal.Exclusivity.EXCLUSIVE}
  keymode={Astal.Keymode.ON_DEMAND}
  anchor={
    Astal.WindowAnchor.TOP | Astal.WindowAnchor.LEFT | Astal.WindowAnchor.RIGHT
  }
/>

Released under the GPL v3.0 License