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.

21 lines 549 B
export function getStyleHookProps(state, customMapping) { let props = {}; Object.entries(state).forEach(([key, value]) => { if (customMapping?.hasOwnProperty(key)) { const customProps = customMapping[key](value); if (customProps != null) { props = { ...props, ...customProps }; } return; } if (value === true) { props[`data-${key.toLowerCase()}`] = ''; } else if (value) { props[`data-${key.toLowerCase()}`] = value.toString(); } }); return props; }