Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | import { checkboxAnatomy as parts } from "@chakra-ui/anatomy";
import {
mode,
PartsStyleFunction,
PartsStyleObject,
SystemStyleFunction,
SystemStyleObject,
} from "@chakra-ui/theme-tools";
const baseStyleControl: SystemStyleFunction = (props) => {
const { colorScheme: c } = props;
return {
w: "100%",
transitionProperty: "box-shadow",
transitionDuration: "normal",
border: "2px solid",
borderRadius: "sm",
borderColor: "inherit",
color: "white",
_checked: {
bg: mode(`${c}.500`, `${c}.200`)(props),
borderColor: mode(`${c}.500`, `${c}.200`)(props),
color: mode("white", "gray.900")(props),
_hover: {
bg: mode(`${c}.600`, `${c}.300`)(props),
borderColor: mode(`${c}.600`, `${c}.300`)(props),
},
_disabled: {
borderColor: mode("gray.200", "transparent")(props),
bg: mode("gray.200", "whiteAlpha.300")(props),
color: mode("gray.500", "whiteAlpha.500")(props),
},
},
_indeterminate: {
bg: mode(`${c}.500`, `${c}.200`)(props),
borderColor: mode(`${c}.500`, `${c}.200`)(props),
color: mode("white", "gray.900")(props),
},
_disabled: {
bg: mode("gray.100", "whiteAlpha.100")(props),
borderColor: mode("gray.100", "transparent")(props),
},
_focus: {
boxShadow: "outline",
},
_invalid: {
borderColor: mode("red.500", "red.300")(props),
},
};
};
const baseStyleLabel: SystemStyleObject = {
userSelect: "none",
_disabled: { opacity: 0.4 },
};
const baseStyleIcon: SystemStyleObject = {
transitionProperty: "transform",
transitionDuration: "normal",
};
const baseStyle: PartsStyleFunction<typeof parts> = (props) => ({
icon: baseStyleIcon,
control: baseStyleControl(props),
label: baseStyleLabel,
});
const sizes: Record<string, PartsStyleObject<typeof parts>> = {
sm: {
control: { h: 3, w: 3 },
label: { fontSize: "sm" },
icon: { fontSize: "0.45rem" },
},
base: {
control: { h: 3.5, w: 3.5 },
label: { fontSize: "sm" },
icon: { fontSize: "0.5rem" },
},
md: {
control: { w: 4, h: 4 },
label: { fontSize: "md" },
icon: { fontSize: "0.625rem" },
},
lg: {
control: { w: 5, h: 5 },
label: { fontSize: "lg" },
icon: { fontSize: "0.625rem" },
},
};
const defaultProps = {
size: "base",
colorScheme: "blue",
};
export const Checkbox = {
parts: parts.keys,
baseStyle,
sizes,
defaultProps,
};
|