cLib.DButton

VGUI - Basic Updated: Dec 10, 2025

cLib.DButton

Styled button with hover/press states and optional icon.

Basic Usage

local btn = vgui.Create("cLib.DButton", parent)
btn:SetSize(cLib.Scale(120), cLib.Scale(35))
btn:SetText("Click Me")

btn.DoClick = function()
    print("Button clicked!")
end

Methods

MethodDescription
SetText(string)Set button text
SetIcon(path)Set icon material path
SetBackgroundColor(Color)Normal background
SetHoverColor(Color)Hover background
SetPressedColor(Color)Pressed background
SetTextColor(Color)Text color
SetTextHoverColor(Color)Text color on hover
SetRoundness(number)Corner roundness
SetEnabled(bool)Enable/disable button

With Icon

local btn = vgui.Create("cLib.DButton", parent)
btn:SetSize(cLib.Scale(150), cLib.Scale(35))
btn:SetText("Save")
btn:SetIcon("icon16/disk.png")

Custom Colors

local btn = vgui.Create("cLib.DButton", parent)
btn:SetText("Danger")

btn:SetBackgroundColor(Color(200, 60, 60))
btn:SetHoverColor(Color(220, 80, 80))
btn:SetPressedColor(Color(180, 40, 40))
btn:SetTextColor(Color(255, 255, 255))

Primary/Secondary Styles

-- Primary button (accent color)
local primary = vgui.Create("cLib.DButton", parent)
primary:SetText("Confirm")
primary:SetBackgroundColor(cLib.GetColor("cLib.accent"))
primary:SetHoverColor(cLib.GetColor("cLib.accentHover"))

-- Secondary button (subtle)
local secondary = vgui.Create("cLib.DButton", parent)
secondary:SetText("Cancel")
secondary:SetBackgroundColor(Color(60, 60, 65))

Disabled State

local btn = vgui.Create("cLib.DButton", parent)
btn:SetText("Not Available")
btn:SetEnabled(false)

cLib.DIconButton

Icon-only button without text.

local iconBtn = vgui.Create("cLib.DIconButton", parent)
iconBtn:SetSize(cLib.Scale(32), cLib.Scale(32))
iconBtn:SetIcon("icon16/cog.png")

-- Customize
iconBtn:SetIconColor(Color(200, 200, 200))
iconBtn:SetIconHoverColor(Color(255, 255, 255))
iconBtn:SetIconPadding(6)  -- Padding around icon
iconBtn:SetRoundness(4)

iconBtn.DoClick = function()
    OpenSettings()
end