Toggle button that tints itself with a configurable accent colour when active.
Formsformstogglecolortintbutton
Summary
ColorToggleButton extends ToggleButton with per-instance tint colors, a ripple press animation, and a selection overlay. The background color is driven entirely by the tint values, making it straightforward to build color-coded toggle grids without USS variants.
Typical use cases:
Color picker palette items
Labeled color-coded category toggles
Any toggle grid where each item has a distinct brand or theme color
Properties
Name
Description
Options
IsSelected
Inherited from ToggleButton. Gets or sets the selected state.
bool
TintColor
The background tint used when the button is in its default (unselected) state.
Color (read-only; use SetTintColor to change)
SelectedTintColor
The background tint used when the button is selected.
Color (read-only; use SetSelectedTintColor to change)
USS Classes
Class
Description
toggleButton
Root element (inherited from ToggleButton).
toggleButton__image
Image layer, 100% size, scale-to-fit (inherited).
toggleButton--selected
Modifier applied when selected (inherited).
toggleButton__icon
Optional icon element overlaid on the colored background.
toggleButton__ripple
Primary ripple circle that expands on press.
toggleButton__rippleSecondary
Secondary ripple circle for the layered ripple effect.
toggleButton__selectedOverlay
Overlay element shown when selected.
toggleButton__selectedOverlay--visible
Modifier that makes the selected overlay visible.
Events
Name
Description
Arguments
OnClicked
Inherited from ToggleButton. Fired on every pointer-down regardless of current state.
none
Constructors
Signature
Description
ColorToggleButton(Color tintColor)
Creates a button with the same tint color for both selected and unselected states.
ColorToggleButton(Color tintColor, Color selectedTintColor)
Creates a button with distinct tints for each state.
Public Methods
Signature
Description
SetTintColor(Color color)
Updates the unselected background tint at runtime.
SetSelectedTintColor(Color color)
Updates the selected background tint at runtime.
SetImage(Texture2D texture)
Inherited. Sets the icon/image on the button.
ForceSelect()
Inherited. Sets IsSelected = true without firing OnClicked.
ForceDeselect()
Inherited. Sets IsSelected = false without firing OnClicked.