@intility/bifrost-react
Version:
React library for Intility's design system, Bifrost.
44 lines (43 loc) • 1.69 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { forwardRef } from "react";
import classnames from "classnames";
import CheckboxIcon from "../common/CheckboxIcon.internal.js";
/**
* Checkbox, radio button, or a switch toggle
*/ const Checkbox = /*#__PURE__*/ forwardRef(({ label, indeterminate = false, hideLabel = false, type = "checkbox", button = false, small = false, className, align, style, inputClassName, inputStyle, labelProps, ...props }, ref)=>{
if (!align) align = type === "switch" ? "right" : "left";
return /*#__PURE__*/ _jsxs("label", {
htmlFor: props.id,
...labelProps,
className: classnames("bf-checkbox", "bf-open-sans", className, labelProps?.className, {
"bf-switch-wrapper": type === "switch",
"bf-checkbox-hidelabel": hideLabel,
"bf-checkbox-button": button,
"bf-checkbox-small": small,
"bf-checkbox-right": align === "right"
}),
style: {
...style,
...labelProps?.style
},
children: [
/*#__PURE__*/ _jsx("input", {
type: type === "radio" ? "radio" : "checkbox",
...props,
ref: ref,
className: inputClassName,
style: inputStyle
}),
/*#__PURE__*/ _jsx(CheckboxIcon, {
type: type,
indeterminate: indeterminate
}),
/*#__PURE__*/ _jsx("span", {
className: "bf-checkbox-text",
children: label
})
]
});
});
Checkbox.displayName = "Checkbox";
export default Checkbox;