Skip to content

Components

Leo Codes edited this page Sep 29, 2024 · 5 revisions

Components

In OSUI's definition. A component is a Structure that is meant to render on the screen. OSUI components work similarly to React or HTML components. But not exactly

How to use a component

Each component has it's own use case and how-to. But simply call a function and send it to other components or the screen

func main() {
    app := ui.Div( // Div component
        ui.Text("Hello, World!") // Text component
    )

    screen := osui.NewScreen(app)
    screen.Run()
}

Component Params

Most components have a .Param() function, This functions is for changing the params of a function. Each function has it's own Paramters with the name <component-name>Params

ui.Div

A Div is a component that handles multiple components at once

ui.Div(components...)
ui.Div(ui.Text("Hello, World!"))

ui.Button

A Button can be clicked with the enter key while it's selected

ui.Button(text)
ui.Button("Click me!")

ui.InputBox

A InputBox takes user input from the user

ui.InputBox(max_size)
ui.InputBox(20)

ui.Menu

A Menu prompts the user to select a list of items

ui.Menu(items...)
ui.Menu("Item 1", "Item 2", "Item 3", "Item 4", "Item 5")

ui.Paginator

A Paginator. Like a div. Puts multiple components into one single component In a tab style

ui.Paginator(components...)
ui.Paginator(ui.Text("Hello, World!"))

ui.Text

A Text. Renders text.. That's it

ui.Text(text)
ui.Text("Hello, World!")

Clone this wiki locally