Garry's Mod Wiki



Panel:SetFGColor( number r or color, number g, number b, number a )


Sets the foreground color of a panel.

For a Label or RichText, this is the color of its text.

This function calls Panel:SetFGColorEx internally.

This doesn't apply to all VGUI elements (such as DLabel) and its function varies between them


1 number r or color
The red channel of the color, or a Color. If you pass the latter, the following three arguments are ignored.
2 number g
The green channel of the color.
3 number b
The blue channel of the color.
4 number a
The alpha channel of the color.


Creates a Label and sets its text color to white.

local label = vgui.Create( "Label" ) label:SetFGColor( Color( 255, 255, 255, 255 ) )


Sets the foreground color of a RichText to match the chat box format.

-- Create a window frame TextFrame = vgui.Create("DFrame") TextFrame:SetSize(200, 50) TextFrame:Center() TextFrame:SetTitle("This is a color test") TextFrame:MakePopup() -- RichText panel local richtext = vgui.Create("RichText", TextFrame) richtext:Dock(FILL) -- Sample text richtext:SetText("Here is some light green text.") -- When the panel is ready for layout, make the text light green function richtext:PerformLayout() self:SetFGColor(Color(153, 255, 153)) end

Special Pages



Render Time: 71ms

DB GetPage 47
Generate Html 9
SaveChanges (1) 5
Render Body 0
Render Sidebar 6