Nighty Docs
  • About Nighty
  • Getting Started
    • First Launch
    • Usage Guide
  • Custom Scripts
    • Scripting Reference
  • 🛠️Troubleshooting
    • The application did not respond / Unknown Integration
    • Common solutions to all issues
    • Unable to launch
    • App is just a white box, UI not appearing / looking weird
    • Retrieving License Key
    • Flagged key
    • Rich Presence doesn't show up
  • UI SCRIPTING
    • API Reference
      • Tab
      • CardContainer
      • Card
      • Group
      • UI Elements
        • Text
        • Button
        • Input
        • Image
        • Toggle
        • Select
        • Checkbox
        • Table
Powered by GitBook
On this page
  • class UI.Button
  • Events

Was this helpful?

  1. UI SCRIPTING
  2. API Reference
  3. UI Elements

Button

PreviousTextNextInput

Last updated 4 months ago

Was this helpful?

class UI.Button

All attributes are read/write: You can access (read) and modify (set) any attribute at any time, and the changes will immediately reflect in the UI.

# setting up click handler
def click_handler():
    print('clicked')

# Creating basic button
card.create_ui_element(UI.Button, label="Click me!", onClick=click_handler)

# Setting attributes
button = card.create_ui_element(
    UI.Button,
    label="Click me!",
    variant="ghost",
    size="sm",
    color="danger",
    full_width=True,
    onClick=click_handler
)

##################################
# Example with asnychronus updates

button = card.create_ui_element(UI.Button, label="Submit")

async def click_handler():
    button.loading=True
    # Do some async tasks, for example fetch data from an API...
    button.loading=False
    # perform other updates

button.onClick = click_handler
Attribute
Value

label

any string

variant

"solid"

"bordered"

"ghost"

"light"

"flat"

"cta" Default: "solid"

color

"primary"

"default"

"success"

"danger"

Note: If cta variant is used, custom color will not be applied.

Default: "primary"

size

"sm"

"md" Default: "md"

full_width

True | False Default: False

disabled

True | False Default: False

loading

True | False Default: False

margin

visible

Events

Event
Arguments
Description

onClick

-

Triggered when the button is clicked.

See . Default: "m-0"

See . Default: True

Margin
Visible