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
tsx
<box orientation={Gtk.Orientation.HORIZONTAL}>
<Child />
<Child />
<Child />
</box>
button
tsx
<button onClicked={() => print("clicked")}>
<Child />
</button>
centerbox
tsx
<centerbox orientation={Gtk.Orientation.HORIZONTAL}>
<Child $type="start" />
<Child $type="center" />
<Child $type="end" />
</centerbox>
drawingarea
tsx
<drawingarea
$={(self) =>
self.set_draw_func((area, cr, width, height) => {
//
})
}
/>
entry
tsx
<entry
placeholderText="Start typing..."
text=""
onNotifyText={({ text }) => print(text)}
/>
image
tsx
<image
file="/path/to/file.png"
iconName="system-search-symbolic"
pixelSize={16}
/>
label
tsx
<label
label="<span foreground='blue'>text</span>"
useMarkup
wrap
ellipsize={Pango.EllipsizeMode.END}
/>
levelbar
tsx
<levelbar
orientation={Gtk.Orientation.HORIZONTAL}
widthRequest={200}
value={0.5}
/>
menubutton
tsx
<menubutton>
button content
<popover>popover content</popover>
</menubutton>
overlay
tsx
<overlay>
<Child />
<Child $type="overlay" />
<Child $type="overlay" />
</overlay>
revealer
tsx
<revealer
transitionType={Gtk.RevealerTransitionType.SLIDE_RIGHT}
revealChild={true}
onNotifyChildRevealed={() => print("animation finished")}
>
<Child />
</revealer>
scrolledwindow
tsx
<scrolledwindow maxContentHeight={500}>
<Child />
</scrolledwindow>
slider
tsx
<slider
value={0.5}
min={0}
max={1}
onChangeValue={({ value }) => print(value)}
/>
stack
tsx
<stack $={(self) => (self.visibleChildName = "child2")}>
<Child $type="named" name="child1" />
<Child $type="named" name="child2" />
</stack>
switch
tsx
<switch active={true} onNotifyActive={({ active }) => print(active)} />
togglebutton
tsx
<togglebutton active={true} onToggled={({ active }) => print(active)} />
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
tsx
<box orientation={Gtk.Orientation.HORIZONTAL}>
<Child />
<Child />
<Child />
</box>
button
tsx
<button onClicked={() => print("clicked")}>
<Child />
</button>
centerbox
tsx
<centerbox orientation={Gtk.Orientation.HORIZONTAL}>
<Child $type="start" />
<Child $type="center" />
<Child $type="end" />
</centerbox>
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
tsx
<drawingarea
onDraw={(self, cr) => {
//
}}
/>
entry
tsx
<entry
onChanged={({ text }) => print("text changed", text)}
onActivate={({ text }) => print("enter", text)}
/>
eventbox
tsx
<eventbox
onClick={(_, event) => {
print(event.modifier, event.button)
}}
/>
icon
tsx
<icon
// named icon or path to a file
icon="/path/to/file.png"
icon="missing-symbolic"
/>
css
icon {
font-size: 16px;
}
label
tsx
<label label="hello" maxWidthChars={16} wrap />
levelbar
tsx
<levelbar value={0.5} widthRequest={200} />
overlay
tsx
<overlay>
<Child>child</Child>
<Child>overlay 1</Child>
</overlay>
revealer
tsx
<revealer
transitionType={Gtk.RevealerTransitionType.SLIDE_RIGHT}
revealChild={true}
onNotifyChildRevealed={() => print("animation finished")}
>
<Child />
</revealer>
scrollable
tsx
<scrollable heightRequest={100}>
<Child />
</scrollable>
slider
tsx
<slider widthRequest={100} onDragged={({ value }) => print(value)} />
stack
tsx
<stack $={(self) => (self.visibleChildName = "child2")}>
<Child name="child1" />
<Child name="child2" />
</stack>
switch
tsx
<switch active={true} onNotifyActive={({ active }) => print(active)} />
overlay
tsx
<overlay>
<Child>child</Child>
<Child>overlay 1</Child>
<Child>overlay 1</Child>
</overlay>
togglebutton
tsx
<togglebutton active={true} onToggled={({ active }) => print(active)} />
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
}
/>