Skip to content

PixelUI.ProgressBar ​

Extends: PixelUI.Widget

A progress indicator widget showing completion status. Supports determinate and indeterminate modes with optional labels.

Properties ​

NameTypeDescription
valuenumberCurrent progress value
minnumberMinimum progress value
maxnumberMaximum progress value
indeterminatebooleanWhether to show an animated indeterminate state
labelstring?Optional label text to display
showPercentbooleanWhether to show percentage text
trackColorPixelUI.ColorBackground track color
fillColorPixelUI.ColorForeground fill color
textColorPixelUI.ColorColor for text (label and percentage)

Methods ​

new ​

lua
new()

_clampValue ​

lua
_clampValue()

_stopIndeterminateAnimation ​

lua
_stopIndeterminateAnimation()

_startIndeterminateAnimation ​

lua
_startIndeterminateAnimation()

setRange ​

lua
setRange()

getRange ​

lua
getRange()

setValue ​

lua
setValue()

getValue ​

lua
getValue()

getPercent ​

lua
getPercent()

setIndeterminate ​

lua
setIndeterminate()

isIndeterminate ​

lua
isIndeterminate()

setLabel ​

lua
setLabel()

setShowPercent ​

lua
setShowPercent()

setColors ​

lua
setColors()

draw ​

lua
draw()

handleEvent ​

lua
handleEvent()

Examples ​

Basic
lua
local pixelui = require("pixelui")
local app = pixelui.app()

-- Simple progress bar
local progress = app:progressbar({
    x = 2, y = 2,
    width = 30, height = 1,
    value = 50,
    min = 0,
    max = 100,
    showPercent = true
})
app.root:addChild(progress)

app:run()
Advanced
lua
local pixelui = require("pixelui")
local app = pixelui.app()

-- Progress bar with animation and custom styling
local progress = app:progressbar({
    x = 2, y = 2,
    width = 40, height = 2,
    value = 0,
    min = 0,
    max = 100,
    showPercent = true,
    label = "Downloading...",
    trackColor = colors.gray,
    fillColor = colors.green,
    textColor = colors.white
})

-- Indeterminate loading indicator
local loadingBar = app:progressbar({
    x = 2, y = 6,
    width = 40, height = 1,
    indeterminate = true,
    fillColor = colors.cyan
})

-- Animate the determinate progress
app:spawnThread(function(ctx)
    for i = 0, 100, 2 do
        progress:setValue(i)
        ctx:sleep(0.1)
    end
    progress:setLabel("Complete!")
end)

app.root:addChild(progress)
app.root:addChild(loadingBar)

app:run()

Released under the MIT License.