menu_bookDocumentation

Inspector property attributes — Range, Group, ShowIf, Title, Feature, and more

calendar_today May 5, 2026 schedule ~1 min read person patrickjr verified 50

Inspector Property Attributes

Attributes control how component properties appear in the s&box editor inspector. Apply them alongside [Property] on your component fields to improve usability — grouping related settings, adding sliders, showing conditional fields, and validating values.

These attributes only affect the editor UI. They have no runtime cost and don't change how properties serialize or behave in code.

Layout & Grouping

Group related properties together visually:

CSHARP
[Property, Group( "Movement" )]
public float MoveSpeed { get; set; } = 200f;

[Property, Group( "Movement" )]
public float JumpForce { get; set; } = 300f;

// Collapsible group with a checkbox toggle
[Property, ToggleGroup( "UseHelpers" )]
public bool UseHelpers { get; set; } = true;

// Separate tab in the inspector
[Property, Feature( "Advanced" )]
public float AdvancedValue { get; set; }

// Bool that enables/disables the feature tab
[Property, FeatureEnabled( "Advanced" )]
public bool ShowAdvanced { get; set; }

Display

CSHARP
[Property, Title( "Max HP" )]          // rename in inspector
public float MaxHealth { get; set; } = 100f;

[Property, Header( "Combat Settings" )] // section header above property
public float Damage { get; set; }

[Property, Space]                       // visual gap above
public float SomeValue { get; set; }

[Property, Hide]                        // exists but invisible
public float InternalValue { get; set; }

[Property, ReadOnly]                    // visible but not editable
public float ComputedValue { get; set; }

[Property, Advanced]                    // hidden unless user expands "Advanced"
public float RareOption { get; set; }

[Property, Order( 100 )]               // override source-order position
public float LateProperty { get; set; }

Numeric Controls

CSHARP
[Property, Range( 0f, 100f )]          // slider, clamped to range
public float Health { get; set; }

[Property, Range( 0f, 1f, 0.01f )]     // slider with step size
public float Opacity { get; set; }

[Property, Step( 10 )]                 // increment by 10 on drag
public int BulletCount { get; set; }

Conditional Visibility

Show or hide properties based on the value of another property:

CSHARP
[Property]
public bool IsRanged { get; set; }

[Property, ShowIf( nameof(IsRanged), true )]
public float Range { get; set; }

[Property, HideIf( nameof(IsRanged), true )]
public float MeleeReach { get; set; }

String Controls

CSHARP
[Property, TextArea]
public string Description { get; set; }

[Property, Placeholder( "Enter player name..." )]
public string PlayerName { get; set; }

[Property, InputAction]    // dropdown of configured input actions
public string AttackInput { get; set; } = "Attack1";

[Property, FilePath( "vmdl" )]
public string ModelPath { get; set; }

Enum Flags

CSHARP
[Flags]
public enum DamageType { Fire = 1, Ice = 2, Poison = 4 }

[Property, Flags]
public DamageType Resistances { get; set; }

Validation

Show a warning or error in the inspector if a value is invalid:

CSHARP
[Property, Validate( nameof(IsHealthValid), "Health must be > 0", LogLevel.Error )]
public float MaxHealth { get; set; } = 100f;

bool IsHealthValid() => MaxHealth > 0f;

Inline Editing

CSHARP
[Property, InlineEditor]   // shows struct fields inline instead of in a popup
public MyConfig Config { get; set; }

[Property, WideMode]       // fills full width, label above
public Vector3 BigVector { get; set; }
Was this helpful?