Skip to content

Basic Syntax

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

Elements

Elements are basically functions stacked on top of each other in an array separated by commas that each return a jsUI Element instance.

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

Styling

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

Component()
    .propertyMethod()

Nested 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>

Non-nested elements

This may change in the future, but some elements only accept text arguments, like Text(), Hyperlink(), Button(), etc. accept the most used attribute(s) as their arguments for convenient shorthands.

Example

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

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