# First Widgets On this page you will learn about the JSX syntax. To learn about it more in depth you can read the [Gnim docs](https://aylur.github.io/gnim/jsx.html). > [!TIP] > > `gnim` symbols is reexported from the `ags` module. ## Entry point of applications Every application's entry point is an `app.start` invocation. `app` is a singleton instance of [Gtk.Application](https://docs.gtk.org/gtk4/class.Application.html). ```ts [ app.ts] import app from "ags/gtk4/app" app.start({ main() { // you will instantiate Widgets here // and setup anything else if you need }, }) ``` ## Root of every shell component: Window Desktop Shells are composed of widgets. A widget is a piece of UI that has its own logic and style. A widget can be as small as a button or an entire bar. The top level - also known as a root - widget is always a [Window](https://aylur.github.io/libastal/astal4/class.Window.html). ```tsx [widget/Bar.tsx] function Bar(monitor = 0) { return ( Content of the widget ) } app.start({ main() { Bar(0) Bar(1) // instantiate for each monitor }, }) ``` > [!IMPORTANT] > > In Gtk4 unlike other widgets, window widgets are not visible by default. Don't > forget to explicitly make it `visible`. ## Creating and nesting widgets Widgets are JavaScript functions which return `GObject.Object` (usually `Gtk.Widget`) instances by using JSX expressions. :::code-group ```tsx [MyButton.tsx] function MyButton() { return ( ) } ``` ::: Now that you have declared `MyButton`, you can nest it into another component. ```tsx function MyBar() { return ( Click The button ) } ``` Notice that widgets you defined start with a capital letter ``. Lowercase tags are builtin [intrinsic](./intrinsics) widgets, while capital letter is for custom widgets. ## Displaying Data JSX lets you put markup into JavaScript. Curly braces let you “escape back” into JavaScript so that you can embed some variable from your code and display it. ```tsx function MyWidget() { const label = "hello" return } ``` You can also pass JavaScript to markup attributes ```tsx function MyWidget() { const label = "hello" return ) } ``` ```tsx [GObject example] import GObject, { register, property } from "ags/gobject" import { createBinding, createComputed } from "ags" @register() class CounterStore extends GObject.Object { @property(Number) count = 0 } function Counter() { const counter = new CounterStore() function increment() { counter.count += 1 } const count = createBinding(count, "count") const label = createComputed(() => count().toString()) return ( ) } ``` ::: Notice how in the `createComputed` body `count` is called as a function to track it automatically as a dependency for the derived `label` property. > [!TIP] > > There is a shorthand for `createComputed`. > > ```ts > // these two lines mean and do the same thing > const label = createComputed(() => count().toString()) > const label = count((c) => c.toString()) > ``` ## Integrating external programs Other than the aforementioned functions to manage state, AGS provides ways to integrate CLI tools you might be already familiar with: [`createPoll`](./utilities#createpoll) which polls a program at each given interval and [`createSubprocess`](./utilities#createsubprocess) which launches a given program and monitors its standard output. As an example let's say you want to use the `date` CLI command to get a formatted date. ```tsx const date = createPoll("", 1000, `bash -c "date +%H:%M"`) return