UNPKG

@gravity-ui/uikit

Version:

Gravity UI base styling and components

24 lines (23 loc) 1.2 kB
'use client'; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import * as React from 'react'; import { useCheckbox } from "../../hooks/private/index.js"; import { ControlLabel } from "../ControlLabel/index.js"; import { block } from "../utils/cn.js"; import "./Switch.css"; const b = block('switch'); export const Switch = React.forwardRef(function Switch(props, ref) { const { size = 'm', disabled = false, content, children, title, style, className, qa } = props; const { checked, inputProps } = useCheckbox({ ...props, controlProps: { ...props.controlProps, role: 'switch' }, }); const text = content || children; const control = (_jsxs("span", { className: b('indicator'), children: [_jsx("input", { ...inputProps, className: b('control') }), _jsx("span", { className: b('outline') }), _jsx("span", { className: b('slider') })] })); return (_jsx(ControlLabel, { ref: ref, title: title, style: style, size: size, disabled: disabled, className: b({ size, disabled, checked, }, className), labelClassName: b('text'), qa: qa, control: control, children: text })); }); //# sourceMappingURL=Switch.js.map