Skip to main content

Overview

Pglet UI is built of controls. Most controls are composed from multiple HTML elements, have finished functionality and sane defaults to make UI development as quick and pleasant as possible. For example, Textbox control is not just <input type="text"> in terms of HTML, but it has an attached label, description, validation message and a help tip.

Controls are organized into hierarchy, or a tree, where each control has a parent (except Page) and container controls like Stack, Dropdown can contain child controls, for example:

Page
โ”œโ”€ Textbox
โ”œโ”€ Dropdown
โ”‚ โ”œโ”€ Option
โ”‚ โ””โ”€ Option
โ””โ”€ Stack
โ”œโ”€ Button
โ””โ”€ Button

Control ID

Every control on a page has an ID. If id is not specified when adding a control it will be auto-generated. Auto-generated IDs have format of _{number}, for example _1, _2. Add command always returns the ID of a control which can be saved for future reference.

User-defined IDs can contain alphanumerics (A-Za-z0-9), dash (-) and underscore (_). However, user-defined ID should not start from _ and cannot contain : which is used to separate parts of an unique ID.

Unique ID

To guarantee the uniqueness of user-defined IDs across the page Pglet automatically prefixes them with parent ID when adding control to a page. Only user-defined IDs will be used as parts of unique ID.

For example, you may want to add a Button with id=ok into two stacks: one with an auto-generated ID _1 and another one with user-defined id=footer:

...
Stack id=_1
โ””โ”€ Button id=ok
Stack id=footer
โ””โ”€ Button id=footer:ok

Once controls added to a page the ID of a second button will be prefixed with footer: and thus it will be referenced later as footer:ok, for example as event target.

Common properties

All Pglet controls have the following properties:

NameTypeDefaultDescription
idstringAuto-generated or user-defined control ID.
visiblebooltrueDefines whether control is visible.
disabledboolfalseDefines whether control and all its children (if any) are disabled.
widthstringWidth of the control, for example 100px, 50%.
heightstringHeight of the control.
paddingstringPadding of the control.
marginstringMargin of the control.