cLib.DCheckBox

VGUI - Input Updated: Dec 10, 2025

cLib.DCheckBox

Styled checkbox for boolean options.

Basic Usage

local check = vgui.Create("cLib.DCheckBox", parent)
check:SetValue(true)

check.OnChange = function(self, value)
    print("Checked:", value)
end

Methods

MethodDescription
SetValue(bool)Set checked state
GetValue()Get checked state
Toggle()Toggle state
SetCheckColor(Color)Checkmark color

cLib.DCheckBoxLabel

Checkbox with attached label.

local check = vgui.Create("cLib.DCheckBoxLabel", parent)
check:SetText("Enable notifications")
check:SetValue(true)
check:Dock(TOP)
check:DockMargin(0, cLib.Scale(5), 0, cLib.Scale(5))

check.OnChange = function(self, value)
    Settings.notifications = value
end

Methods

MethodDescription
SetText(string)Set label text
SetValue(bool)Set checked state
GetValue()Get checked state
SetTextColor(Color)Label color
SetFont(string)Label font

Settings Panel Example

function CreateSettingsPanel(parent)
    local settings = {}
    
    -- Sound effects
    local sfx = vgui.Create("cLib.DCheckBoxLabel", parent)
    sfx:SetText("Enable sound effects")
    sfx:SetValue(GetSetting("sfx", true))
    sfx:Dock(TOP)
    sfx:DockMargin(0, 0, 0, cLib.Scale(8))
    sfx.OnChange = function(s, v) settings.sfx = v end
    
    -- Music
    local music = vgui.Create("cLib.DCheckBoxLabel", parent)
    music:SetText("Enable background music")
    music:SetValue(GetSetting("music", true))
    music:Dock(TOP)
    music:DockMargin(0, 0, 0, cLib.Scale(8))
    music.OnChange = function(s, v) settings.music = v end
    
    -- Notifications
    local notif = vgui.Create("cLib.DCheckBoxLabel", parent)
    notif:SetText("Show notifications")
    notif:SetValue(GetSetting("notifications", true))
    notif:Dock(TOP)
    notif:DockMargin(0, 0, 0, cLib.Scale(8))
    notif.OnChange = function(s, v) settings.notifications = v end
    
    -- HUD
    local hud = vgui.Create("cLib.DCheckBoxLabel", parent)
    hud:SetText("Show HUD elements")
    hud:SetValue(GetSetting("hud", true))
    hud:Dock(TOP)
    hud.OnChange = function(s, v) settings.hud = v end
    
    return settings
end