Expose name prop in Checkbox component

This commit is contained in:
Alex Holliday committed 2024-12-10 11:29:57 +08:00
1 parent 3e21eb0a12
commit de149503ae
1 file changed
+4 -1
@@ -30,6 +30,7 @@ import "./index.css";
const Checkbox = ({ const Checkbox = ({
id, id,
name,
label, label,
size = "medium", size = "medium",
isChecked, isChecked,
@@ -46,6 +47,7 @@ const Checkbox = ({
control={ control={
<MuiCheckbox <MuiCheckbox
checked={isDisabled ? false : isChecked} checked={isDisabled ? false : isChecked}
name={name}
value={value} value={value}
onChange={onChange} onChange={onChange}
icon={<CheckboxOutline />} icon={<CheckboxOutline />}
@@ -54,7 +56,7 @@ const Checkbox = ({
"aria-label": "controlled checkbox", "aria-label": "controlled checkbox",
id: id, id: id,
}} }}
sx={{ sx={{
"&:hover": { backgroundColor: "transparent" }, "&:hover": { backgroundColor: "transparent" },
"& svg": { width: sizes[size], height: sizes[size] }, "& svg": { width: sizes[size], height: sizes[size] },
alignSelf: "flex-start", alignSelf: "flex-start",
@@ -89,6 +91,7 @@ const Checkbox = ({
Checkbox.propTypes = { Checkbox.propTypes = {
id: PropTypes.string.isRequired, id: PropTypes.string.isRequired,
name: PropTypes.string,
label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired, label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,
size: PropTypes.oneOf(["small", "medium", "large"]), size: PropTypes.oneOf(["small", "medium", "large"]),
isChecked: PropTypes.bool.isRequired, isChecked: PropTypes.bool.isRequired,