UNPKG

@base-ui-components/react

Version:

Base UI is a library of headless ('unstyled') React components and low-level hooks. You gain complete control over your app's CSS and accessibility features.

28 lines 735 B
import * as React from 'react'; import { useMenuItem } from '../item/useMenuItem.js'; import { mergeReactProps } from '../../utils/mergeReactProps.js'; export function useMenuRadioItem(params) { const { checked, setChecked, ...other } = params; const { getRootProps: getMenuItemRootProps, ...menuItem } = useMenuItem(other); const getRootProps = React.useCallback(externalProps => { return getMenuItemRootProps(mergeReactProps(externalProps, { role: 'menuitemradio', 'aria-checked': checked, onClick: event => { setChecked(event.nativeEvent); } })); }, [checked, getMenuItemRootProps, setChecked]); return { ...menuItem, getRootProps, checked }; }