diff --git a/packages/switch-cell/test/__snapshots__/demo.spec.js.snap b/packages/switch-cell/test/__snapshots__/demo.spec.js.snap
index 2e775007a..ecb45e240 100644
--- a/packages/switch-cell/test/__snapshots__/demo.spec.js.snap
+++ b/packages/switch-cell/test/__snapshots__/demo.spec.js.snap
@@ -33,7 +33,7 @@ exports[`renders demo correctly 1`] = `
diff --git a/packages/switch/index.tsx b/packages/switch/index.tsx
index 0cf0622b2..23d9abce8 100644
--- a/packages/switch/index.tsx
+++ b/packages/switch/index.tsx
@@ -1,5 +1,5 @@
import { use } from '../utils';
-import { BLUE } from '../utils/color';
+import { BLUE, GRAY_DARK } from '../utils/color';
import { switchProps, SharedSwitchProps } from './shared';
import { emit, inherit } from '../utils/functional';
import Loading from '../loading';
@@ -20,13 +20,24 @@ function Switch(
slots: DefaultSlots,
ctx: RenderContext
) {
- const { value, loading, disabled, activeValue, inactiveValue } = props;
+ const {
+ size,
+ value,
+ loading,
+ disabled,
+ activeColor,
+ activeValue,
+ inactiveColor,
+ inactiveValue
+ } = props;
- const style = {
- fontSize: props.size,
- backgroundColor: value ? props.activeColor : props.inactiveColor
+ const switchStyle = {
+ fontSize: size,
+ backgroundColor: value ? activeColor : inactiveColor
};
+ const loadingColor = value ? activeColor || BLUE : inactiveColor || GRAY_DARK;
+
function onClick() {
if (!disabled && !loading) {
const newValue = value === activeValue ? inactiveValue : activeValue;
@@ -41,12 +52,12 @@ function Switch(
on: value === activeValue,
disabled
})}
- style={style}
+ style={switchStyle}
onClick={onClick}
{...inherit(ctx)}
>
- {loading && }
+ {loading && }
);
diff --git a/packages/switch/test/__snapshots__/demo.spec.js.snap b/packages/switch/test/__snapshots__/demo.spec.js.snap
index 8046a37e9..ea58099e8 100644
--- a/packages/switch/test/__snapshots__/demo.spec.js.snap
+++ b/packages/switch/test/__snapshots__/demo.spec.js.snap
@@ -15,7 +15,7 @@ exports[`renders demo correctly 1`] = `