package.dist.esm.components.switch.switch.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of react Show documentation
Show all versions of react Show documentation
Responsive and accessible React UI components built with React and Emotion
The newest version!
"use strict";
"use client";
import { jsx } from 'react/jsx-runtime';
import { Switch, useSwitchContext } from '@ark-ui/react/switch';
import { forwardRef } from 'react';
import { dataAttr } from '../../utils/attr.js';
import { createSlotRecipeContext } from '../../styled-system/create-slot-recipe-context.js';
import { chakra } from '../../styled-system/factory.js';
const {
withProvider,
withContext,
useStyles: useSwitchStyles,
PropsProvider
} = createSlotRecipeContext({ key: "switch" });
const SwitchRootProvider = withProvider(Switch.RootProvider, "root", { forwardAsChild: true });
const SwitchRoot = withProvider(
Switch.Root,
"root",
{ forwardAsChild: true }
);
const SwitchPropsProvider = PropsProvider;
const SwitchLabel = withContext(
Switch.Label,
"label",
{ forwardAsChild: true }
);
const SwitchControl = withContext(
Switch.Control,
"control",
{ forwardAsChild: true }
);
const SwitchThumb = withContext(
Switch.Thumb,
"thumb",
{ forwardAsChild: true }
);
const SwitchIndicator = forwardRef(function SwitchIndicator2(props, ref) {
const api = useSwitchContext();
const styles = useSwitchStyles();
const { fallback, children, ...rest } = props;
return /* @__PURE__ */ jsx(
chakra.span,
{
ref,
"data-checked": dataAttr(api.checked),
...rest,
css: [styles.indicator, props.css],
children: api.checked ? children : fallback
}
);
});
const SwitchThumbIndicator = forwardRef(function SwitchThumbIndicator2(props, ref) {
const api = useSwitchContext();
const { fallback, children, ...rest } = props;
return /* @__PURE__ */ jsx(chakra.span, { ref, "data-checked": dataAttr(api.checked), ...rest, children: api.checked ? children : fallback });
});
const SwitchContext = Switch.Context;
const SwitchHiddenInput = Switch.HiddenInput;
export { SwitchContext, SwitchControl, SwitchHiddenInput, SwitchIndicator, SwitchLabel, SwitchPropsProvider, SwitchRoot, SwitchRootProvider, SwitchThumb, SwitchThumbIndicator, useSwitchStyles };
© 2015 - 2025 Weber Informatics LLC | Privacy Policy