Siticone Logo
Siticone UI
DOCS
v2025.12.15
Docs Expressive Toggle Button

Siticone Expressive Toggle Button

The SiticoneExpressiveToggleButton is a state-aware button that alternates between an "On" (Checked) and "Off" (Unchecked) state when clicked. It builds upon the Expressive system with advanced "Jelly" physics, fluid morphing, and ripple effects. Crucially, it supports completely separate visual definitions (Text, Font, Colors) for its active state, making it ideal for "Play/Pause" or "Follow/Following" scenarios.

Toggle State

Core properties for managing the Checked state.

Property Type Description & Usage Example
IsOn bool toggle.IsOn = true; Gets or sets the checked state. Toggling this triggers the state change animation and fires the CheckedChanged event.
CheckedText string toggle.CheckedText = "Following"; The text displayed when IsOn is true. If empty, it falls back to the standard Text property.
CheckedFont Font toggle.CheckedFont = new Font("Segoe UI", 10, FontStyle.Bold); A specific font to use when the button is checked. Useful for bolding the active state.

Appearance (Colors)

Define specific colors for both the "Off" (Default) and "On" (Checked) states.

Property Type Description & Usage Example
FillColor Color toggle.FillColor = Color.WhiteSmoke; Background color when Off.
CheckedFillColor Color toggle.CheckedFillColor = Color.FromArgb(103, 80, 164); Background color when On.
CheckedForeColor Color toggle.CheckedForeColor = Color.White; Text color when On.
HoverFillColor Color toggle.HoverFillColor = Color.LightGray; Background color on Hover (typically only applied when Off).

Expressive Physics

Control the fluid "Jelly" animations and shape morphing.

Property Type Description & Usage Example
LiquidEffect bool toggle.LiquidEffect = true; Enables fluid wave simulation for shape transitions.
SqueezeOnPress bool toggle.SqueezeOnPress = true; If true, the button indents horizontally when pressed.
BorderRadius int toggle.BorderRadius = 15; Corner roundness in the idle state.
PressedBorderRadius int toggle.PressedBorderRadius = 5; Target corner roundness while pressed (morph target).

Public Methods

Programmatic Interaction
// Flips the state (On -> Off or Off -> On) with animation.
toggle.Toggle();

// Simulates a full click animation without toggling logic (unless wired).
toggle.PerformClickEx();

// Manually triggers the "Shake" error animation.
toggle.TriggerShake();

Events

Checked Changed Event
// Occurs when the IsOn property changes.
toggle.CheckedChanged += (s, e) => 
{
                // e.IsOn gives the new state
                // e.Source tells you if it was Mouse, Keyboard, or Code
    
                if (e.IsOn) 
                StartService();
                else 
                StopService();
};

Detailed Usage Examples

Example 1: Dark Mode Switch

A typical theme toggle that changes text and icon based on state.

C# - Theme Toggle
public void SetupThemeToggle()
{
                // Off State (Light Mode)
    toggleMode.Text = "Light Mode";
    toggleMode.FillColor = Color.WhiteSmoke;
    toggleMode.ForeColorCustom = Color.Black;
    toggleMode.LeftIcon = Properties.Resources.Sun;
    
                // On State (Dark Mode)
    toggleMode.CheckedText = "Dark Mode";
    toggleMode.CheckedFillColor = Color.FromArgb(30, 30, 30);
    toggleMode.CheckedForeColor = Color.White;
    
                // Logic
    toggleMode.CheckedChanged += (s, e) => 
    {
                SetAppTheme(e.IsOn ? Theme.Dark : Theme.Light);
                // Swap icon manually if needed
        toggleMode.LeftIcon = e.IsOn ? Properties.Resources.Moon : Properties.Resources.Sun;
    };
}

Example 2: Play/Pause Button

Using the toggle state to control media playback.

C# - Media Control
public void SetupMediaToggle()
{
    togglePlay.Size = new Size(60, 60);
    togglePlay.BorderRadius = 30; // Circle
    
    togglePlay.Text = ""; // Icon only
    togglePlay.ImageSize = new Size(24, 24);
    
                // Initial Icon
    togglePlay.LeftIcon = Properties.Resources.Play;
    
    togglePlay.CheckedChanged += (s, e) => 
    {
                if (e.IsOn)
        {
            togglePlay.LeftIcon = Properties.Resources.Pause;
            player.Play();
        }
                else
        {
            togglePlay.LeftIcon = Properties.Resources.Play;
            player.Pause();
        }
    };
}