Skip to content

Basic Syntax

Brandon Jordan edited this page Jul 9, 2023 · 13 revisions

Components

Components are functions stacked on top of each other in an array separated by commas.

jsUI.view([
    Component(),
    Component(),
    // …
]);

Styling

To apply styles to a component, simply add the corresponding method using dot notation.

Component()
    .propertyMethod()

Nesting elements

Most elements accept an array of elements as their first or second argument which means that that element can nest elements inside itself.

Div([
    Paragraph("Text")
])

Resulting HTML:

<div>
    <p>Text</p>
</div>

Argument only elements

This may change in the future, but some elements only accept arguments, like Text(), Hyperlink(), Button(), etc. accept the most used attribute as a convenient shorthand

Example

The Hyperlink() element accepts optional text and URL arguments. While these can also be set using it's url() and text() methods, if all you need to do is set these common arguments, so there's no need to chain methods.

Hyperlink("Link Text", "https://example.com")
Clone this wiki locally