reactjsantdant-design-pro

Is there a way to override the colors in Ant design Switch Component


i need to override the default blue (primary color) on Antd Switch Component when checked and change it to red color. is there a way i can do this?

i have tried using style attribute but it didnt work.


Solution

  • You can change the backgroundColor using inline styles like this.

    <Switch style={{backgroundColor: permission.enabled ? 'green' : 'orange'}}
            checked={permission.enabled}
            checkedChildren={'ENABLED'}
            unCheckedChildren={'DISABLED'}
            onChange={(e) => onPermissionChanged(e, permission)} />