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 | import { radioAnatomy as parts } from "@chakra-ui/anatomy";
import {
PartsStyleFunction,
PartsStyleObject,
SystemStyleFunction,
} from "@chakra-ui/theme-tools";
import { Checkbox } from "./Checkbox";
const baseStyleControl: SystemStyleFunction = (props) => {
const { control = {} } = Checkbox.baseStyle(props) as any;
return {
...control,
borderRadius: "full",
pos: "relative",
_checked: {
...control._checked,
_before: {
content: `""`,
display: "inline-block",
pos: "absolute",
top: "50%",
left: "50%",
transform: "translate(-50%, -50%)",
w: "50%",
h: "50%",
borderRadius: "50%",
bg: "currentColor",
},
},
};
};
const baseStyle: PartsStyleFunction<typeof parts> = (props) => ({
label: Checkbox.baseStyle(props).label,
control: baseStyleControl(props),
});
const sizes: Record<string, PartsStyleObject<typeof parts>> = {
sm: {
control: { h: 3, w: 3 },
label: { fontSize: "sm" },
},
base: {
control: { h: 3.5, w: 3.5 },
label: { fontSize: "sm" },
},
md: {
control: { h: 4, w: 4 },
label: { fontSize: "md" },
},
lg: {
control: { h: 5, w: 5 },
label: { fontSize: "lg" },
},
};
const defaultProps = {
size: "base",
colorScheme: "blue",
};
export const Radio = {
parts: parts.keys,
baseStyle,
sizes,
defaultProps,
};
|