s&box
RustCounter-Strike 2s&boxDeadlock
Wiki
Get s&box on Steam
Browse
OverviewGetting StartedCreating GamesEngine & ToolsDocumentationCommunity GamesResources
s&boxDocumentationUiInteractions
SOURCE 2 · C#
Build and play games with s&box.

Facepunch's game engine and creation platform — make games in C#, or jump straight into community games.

Get s&box on Steam

s&box Wiki

  • Overview
  • Getting Started
  • Creating Games
  • Engine & Tools
  • Documentation
  • Community Games
  • Resources

Tools & Community

  • Getting Started
  • Creating Games
  • Engine & Tools
  • Resources

Platforms

  • RustBattle
  • CSBattle
  • Rust Game Wiki
  • CS2 Skins Wiki
  • Deadlock Wiki

About

  • Official Site
  • Developer Wiki
  • GitHub
  • Get on Steam
NOT AFFILIATED WITH FACEPUNCH STUDIOS · © 2026 s&box Wiki (community)
Docs/UI
UI

UI Interactions

Pointer Events

By default, panels do not receive mouse input. You need to enable pointer-events in your stylesheet to make a panel interactable.

.button {
    pointer-events: all;
}

To disable pointer events on a child element (e.g. so clicks pass through to the parent):

.overlay {
    pointer-events: none;
}

onclick

You can handle click events using the onclick attribute in Razor:

<root>
    <div class="button" onclick=@OnButtonClick>Click Me</div>
</root>

@code
{
    void OnButtonClick()
    {
        Log.Info( "Button clicked!" );
    }
}

Or inline with a lambda:

<div class="button" onclick=@(() => Log.Info( "Clicked!" ))>Click Me</div>

You can also handle clicks in C# by overriding OnClick on a Panel subclass:

public class MyButton : Panel
{
    protected override void OnClick( MousePanelEvent e )
    {
        Log.Info( "Clicked!" );
        e.StopPropagation();
    }
}

e.StopPropagation() prevents the event from bubbling up to parent panels.

Other Mouse Events

Attribute / OverrideFires when…
onmouseover / OnMouseOverCursor enters the panel
onmouseout / OnMouseOutCursor leaves the panel
onmousedown / OnMouseDownMouse button is pressed
onmouseup / OnMouseUpMouse button is released
onclick / OnClickPanel is clicked
<div class="card" onmouseover=@OnHover onmouseout=@OnUnhover>Hover Me</div>

@code
{
    void OnHover()   => Log.Info( "Hovered" );
    void OnUnhover() => Log.Info( "Unhovered" );
}

Source: Facepunch/sbox-docs (CC-BY-4.0) · updated 2026-05-10. Read it rendered on the official docs.

More in UI

HudPainter
Localization
Razor Components
Razor Panels
Style Properties
Styling Panels
UI
VirtualGrid
← All documentation

Community wiki — not affiliated with Facepunch Studios. For the latest and most authoritative information, see the official developer wiki.