UNPKG

@nex-ui/react

Version:

🎉 A beautiful, modern, and reliable React component library.

69 lines (66 loc) • 1.73 kB
"use client"; import { jsx } from 'react/jsx-runtime'; import { __DEV__ } from '@nex-ui/utils'; import { useDefaultProps } from '../utils/useDefaultProps.mjs'; import { useStyles } from '../utils/useStyles.mjs'; import { useSlotClasses } from '../utils/useSlotClasses.mjs'; import { useSlot } from '../utils/useSlot.mjs'; import { iconRecipe } from '../../theme/recipes/icon.mjs'; const slots = [ 'root' ]; const Icon = (inProps)=>{ const props = useDefaultProps({ name: 'Icon', props: inProps }); const { as, color, focusable = false, spin = false, size = 'md', width = '1em', height = '1em', ...remainingProps } = props; if (__DEV__ && !as) { console.warn('[Nex UI] Icon: Please pass the "as" property.'); } const ownerState = { ...props, color, as, spin, size, width, height }; const style = useStyles({ ownerState, name: 'Icon', recipe: iconRecipe }); const slotClasses = useSlotClasses({ name: 'Icon', slots }); const [IconRoot, getIconRootProps] = useSlot({ style, elementType: 'svg', externalForwardedProps: remainingProps, classNames: slotClasses.root, a11y: { focusable, 'aria-hidden': props['aria-hidden'] ?? true }, additionalProps: { as, sx: { color, width, height } }, dataAttrs: { size, spin } }); return /*#__PURE__*/ jsx(IconRoot, { ...getIconRootProps() }); }; Icon.displayName = 'Icon'; export { Icon };