Garry's Mod Wiki




The collapsible category allows you to create numerous sections of controls, and have the ability to contract/expand them.

Consider using DCategoryList if you plan on using more than 1 of these.


Derives from Panel.


Panel DCollapsibleCategory:Add( string name )
Adds a new text button to the collapsible category, like the tool menu in Spawnmenu.
DCollapsibleCategory:AnimSlide( table anim, number delta, table data )
This is used internally - although you're able to use it you probably shouldn't. Internal function that handles the open/close animations.
DCollapsibleCategory:DoExpansion( boolean expand )
Forces the category to open or collapse
number DCollapsibleCategory:GetAnimTime()
Returns the expand/collapse animation time set by DCollapsibleCategory:SetAnimTime.
boolean DCollapsibleCategory:GetExpanded()
Returns whether the DCollapsibleCategory is expanded or not.
number DCollapsibleCategory:GetHeaderHeight()
Returns the header height of the DCollapsibleCategory. See also DCollapsibleCategory:SetHeaderHeight.
Panel DCollapsibleCategory:GetList()
No Description
number DCollapsibleCategory:GetPadding()
Doesn't actually do anything. Returns the number set by DCollapsibleCategory:SetPadding.
boolean DCollapsibleCategory:GetPaintBackground()
Returns whether or not the background should be painted.
number DCollapsibleCategory:GetStartHeight()
No Description
DCollapsibleCategory:OnToggle( boolean expanded )
Called by DCollapsibleCategory:Toggle. This function does nothing by itself, as you're supposed to overwrite it.
DCollapsibleCategory:SetAnimTime( number time )
Sets the time in seconds it takes to expand the DCollapsibleCategory
DCollapsibleCategory:SetContents( Panel pnl )
Sets the contents of the DCollapsibleCategory.
DCollapsibleCategory:SetExpanded( boolean expanded = true )
Sets whether the DCollapsibleCategory is expanded or not upon opening the container. You should use DCollapsibleCategory:Toggle or DCollapsibleCategory:DoExpansion instead.
DCollapsibleCategory:SetHeaderHeight( number height )
Sets the header height of the DCollapsibleCategory. See also DCollapsibleCategory:GetHeaderHeight.
DCollapsibleCategory:SetLabel( string label )
Sets the name of the DCollapsibleCategory.
DCollapsibleCategory:SetList( Panel pnl )
No Description
DCollapsibleCategory:SetPadding( number padding )
Doesn't actually do anything.
DCollapsibleCategory:SetPaintBackground( boolean paint )
Sets whether or not the background should be painted.
DCollapsibleCategory:SetStartHeight( number height )
No Description
Toggles the expanded state of the DCollapsibleCategory. See DCollapsibleCategory:GetExpanded for a function to retrieve the expanded state.
No Description
This is used internally - although you're able to use it you probably shouldn't. Used internally to update the "AltLine" property on all "child" panels.


Creates a DCollapsibleCategory panel.

local frame = vgui.Create( "DFrame" ) frame:SetSize( 300, 300 ) frame:Center() frame:MakePopup() local DCollapsible = vgui.Create( "DCollapsibleCategory", frame ) -- Create a collapsible category DCollapsible:SetLabel( "Collapsible Category" ) -- Set the name ( label ) DCollapsible:SetPos( 25, 50 ) -- Set position DCollapsible:SetSize( 250, 100 ) -- Set size DCollapsible:SetExpanded( false ) -- Start collapsed local DermaList = vgui.Create( "DPanelList", DermaPanel ) -- Make a list of items to add to our category (collection of controls) DermaList:SetSpacing( 5 ) -- Set the spacing between items DermaList:EnableHorizontal( false ) -- Only vertical items DermaList:EnableVerticalScrollbar( true ) -- Enable the scrollbar if (the contents are too wide) DCollapsible:SetContents( DermaList ) -- Add DPanelList to our Collapsible Category local CategoryContentOne = vgui.Create( "DCheckBoxLabel" ) -- This section creates a checkbox and CategoryContentOne:SetText( "God mode" ) -- sets up its settings CategoryContentOne:SetConVar( "sbox_godmode" ) CategoryContentOne:SetValue( 0 ) CategoryContentOne:SizeToContents() DermaList:AddItem( CategoryContentOne ) -- Add the checkbox to the category local CategoryContentTwo = vgui.Create( "DLabel" ) -- Make some more content CategoryContentTwo:SetText( "Hello" ) DermaList:AddItem( CategoryContentTwo ) -- Add it to the categoryDCollapsible:SetContents( DermaList ) -- Set the contents of the category to the list

Special Pages



Render Time: 29ms

DB GetPage 1
Generate Html 5
SaveChanges (1) 12
Render Body 0
Render Sidebar 7