Panel¶
Panel metatable helpers for inventory-aware UI behavior, layout, transitions, and drawing.
Overview
liaListenForInventoryChanges(inventory)View Source
Purpose
Starts listening for inventory-related hooks and forwards matching events to this panel.
Realm
Client
Parameters
table inventory The inventory object whose events should be observed.
Example Usage
panel:liaListenForInventoryChanges(inventory)
liaDeleteInventoryHooks(id)View Source
Purpose
Removes inventory hooks that were previously registered for this panel.
Realm
Client
Parameters
number id optional A specific inventory ID to stop listening to, or `nil` to remove all tracked inventory hooks.
Example Usage
panel:liaDeleteInventoryHooks()
panel:liaDeleteInventoryHooks(inventory:getID())
setScaledPos(x, y)View Source
setScaledSize(w, h)View Source
On(name, fn)View Source
Purpose
Appends a callback onto an existing panel method instead of replacing the method entirely.
Realm
Client
Parameters
string name The panel method name to wrap.
function fn The callback to run after the original method.
Example Usage
panel:On("Paint", function(_, w, h)
surface.DrawOutlinedRect(0, 0, w, h)
end)
SetupTransition(name, speed, fn)View Source
Purpose
Creates a transition value that smoothly lerps between `0` and `1` based on a predicate callback.
Realm
Client
Parameters
string name The field name that stores the transition value.
number speed The interpolation speed multiplier.
function fn A callback that returns whether the transition should move toward `1`.
Example Usage
panel:SetupTransition("HoverAmount", 8, function(s)
return s:IsHovered()
end)
FadeHover(col, speed, rad)View Source
BarHover(col, height, speed)View Source
FillHover(col, dir, speed, mat)View Source
Purpose
Fills the panel from a chosen direction while it is hovered.
Realm
Client
Parameters
Color col optional The fill color.
number dir optional The fill direction constant such as `LEFT` or `TOP`.
number speed optional The transition speed.
IMaterial mat optional An optional material to draw instead of a solid rectangle.
Example Usage
panel:FillHover(Color(255, 255, 255, 25), LEFT, 8)
Background(col, rad, rtl, rtr, rbl, rbr)View Source
Purpose
Draws a flat or rounded background in the panel paint hook.
Realm
Client
Parameters
Color col The background color.
number rad optional The rounded corner radius.
boolean rtl optional Whether the top-left corner is rounded when using `draw.RoundedBoxEx`.
boolean rtr optional Whether the top-right corner is rounded.
boolean rbl optional Whether the bottom-left corner is rounded.
boolean rbr optional Whether the bottom-right corner is rounded.
Example Usage
panel:Background(Color(20, 20, 20, 220), 8)
Material(mat, col)View Source
TiledMaterial(mat, tw, th, col)View Source
Purpose
Paints a tiled material across the panel using UV scaling.
Realm
Client
Parameters
IMaterial mat The material to tile.
number tw The horizontal tile size.
number th The vertical tile size.
Color col optional A tint color applied to the tiled material.
Example Usage
panel:TiledMaterial(Material("vgui/white"), 32, 32)
Outline(col, width)View Source
LinedCorners(col, cornerLen)View Source
SideBlock(col, size, side)View Source
Text(text, font, col, alignment, ox, oy, paint)View Source
Purpose
Sets built-in control text or paints centered text manually.
Realm
Client
Parameters
string text The text to display.
string font optional The font name to use.
Color col optional The text color.
number alignment optional The horizontal text alignment constant.
number ox optional Horizontal paint offset.
number oy optional Vertical paint offset.
boolean paint optional Whether to force manual painting even when native text setters exist.
Example Usage
panel:Text("Confirm", "Trebuchet24", color_white)
DualText(toptext, topfont, topcol, bottomtext, bottomfont, bottomcol, alignment, centerSpacing)View Source
Purpose
Paints two stacked text lines with independent fonts and colors.
Realm
Client
Parameters
string toptext The upper text line.
string topfont optional The upper line font.
Color topcol optional The upper line color.
string bottomtext The lower text line.
string bottomfont optional The lower line font.
Color bottomcol optional The lower line color.
number alignment optional The horizontal text alignment.
number centerSpacing optional Extra spacing adjustment around the center.
Example Usage
panel:DualText("Lilia", "Trebuchet24", color_white, "Inventory", "Trebuchet18", Color(180, 180, 180))
Blur(amount)View Source
Purpose
Draws a blurred fullscreen backdrop behind the panel bounds.
Realm
Client
Parameters
number amount optional The maximum blur strength.
Example Usage
panel:Blur(8)
CircleClick(col, speed, trad)View Source
CircleHover(col, speed, trad)View Source
SquareCheckbox(inner, outer, speed)View Source
Purpose
Paints an animated square checkbox fill based on checked state.
Realm
Client
Parameters
Color inner optional The fill color used when checked.
Color outer optional The outer frame color.
number speed optional The transition speed.
Example Usage
checkbox:SquareCheckbox(Color(0, 200, 0), color_white, 14)
CircleCheckbox(inner, outer, speed)View Source
Purpose
Paints an animated circular checkbox fill based on checked state.
Realm
Client
Parameters
Color inner optional The fill color used when checked.
Color outer optional The outer frame color.
number speed optional The transition speed.
Example Usage
checkbox:CircleCheckbox(Color(0, 200, 0), color_white, 14)
AvatarMask(mask)View Source
Purpose
Masks an embedded `AvatarImage` using a custom stencil shape callback.
Realm
Client
Parameters
function mask A drawing callback that defines the stencil mask shape.
Example Usage
panel:AvatarMask(function(_, w, h)
draw.RoundedBox(8, 0, 0, w, h, color_white)
end)
CircleAvatar()View Source
Circle(col)View Source
Purpose
Draws a filled circle that fits inside the panel.
Realm
Client
Parameters
Color col optional The circle color.
Example Usage
panel:Circle(Color(255, 255, 255))
CircleFadeHover(col, speed)View Source
CircleExpandHover(col, speed)View Source
Gradient(col, dir, frac, op)View Source
Purpose
Draws a directional gradient overlay with optional inversion.
Realm
Client
Parameters
Color col The gradient tint color.
number dir optional The gradient direction constant.
number frac optional The fraction of the panel covered by the gradient.
boolean op optional Whether to invert the gradient material direction.
Example Usage
panel:Gradient(Color(0, 0, 0, 180), BOTTOM, 1)
SetOpenURL(url)View Source
Purpose
Opens the provided URL when the panel is clicked.
Realm
Client
Parameters
string url The URL to open in the user's browser.
Example Usage
panel:SetOpenURL("https://example.com")
NetMessage(name, data)View Source
Purpose
Sends a client-to-server net message when the panel is clicked.
Realm
Client
Parameters
string name The net message name.
function data optional A callback that writes additional payload data into the net message.
Example Usage
button:NetMessage("liaRequestAction", function()
net.WriteUInt(1, 8)
end)
Stick(dock, margin, dontInvalidate)View Source
Purpose
Docks the panel with optional uniform margin and parent invalidation.
Realm
Client
Parameters
number dock optional The docking mode such as `FILL` or `TOP`.
number margin optional A uniform dock margin.
boolean dontInvalidate optional Whether to skip invalidating the parent layout.
Example Usage
panel:Stick(TOP, 4)
DivTall(frac, target)View Source
DivWide(frac, target)View Source
SquareFromHeight()View Source
SquareFromWidth()View Source
SetRemove(target)View Source
Purpose
Removes a target panel when this panel is clicked.
Realm
Client
Parameters
Panel target optional The panel to remove, or this panel when omitted.
Example Usage
closeButton:SetRemove(frame)
FadeIn(time, alpha)View Source
HideVBar()View Source
SetTransitionFunc(fn)View Source
ClearTransitionFunc()View Source
Purpose
Clears the default predicate override used by transition helpers.
Realm
Client
Returns
Panel The current panel for chaining.
Example Usage
panel:ClearTransitionFunc()
SetAppendOverwrite(fn)View Source
ClearAppendOverwrite()View Source
Purpose
Clears the temporary method override used by `On`.
Realm
Client
Returns
Panel The current panel for chaining.
Example Usage
panel:ClearAppendOverwrite()