@ui5/webcomponents-react
Version:
React Wrapper for UI5 Web Components and additional components
36 lines (35 loc) • 1.39 kB
JavaScript
'use client';
import { useStylesheet } from '@ui5/webcomponents-react-base';
import { clsx } from 'clsx';
import { forwardRef } from 'react';
import { FlexBoxAlignItems, FlexBoxDirection, FlexBoxJustifyContent, FlexBoxWrap } from '../../enums/index.js';
import { classNames, styleData } from './FlexBox.module.css.js';
import { jsx as _jsx } from "react/jsx-runtime";
/**
* The `FlexBox` builds the container for a flexible box layout by leveraging the CSS flexbox layout.
*/
const FlexBox = /*#__PURE__*/forwardRef((props, ref) => {
const {
children,
justifyContent = FlexBoxJustifyContent.Start,
direction = FlexBoxDirection.Row,
alignItems = FlexBoxAlignItems.Stretch,
displayInline,
wrap = FlexBoxWrap.NoWrap,
className,
fitContainer,
as = 'div',
...rest
} = props;
useStylesheet(styleData, FlexBox.displayName);
const flexBoxClasses = clsx(classNames.flexBox, classNames[`flexBoxDirection${direction}`], classNames[`justifyContent${justifyContent}`], classNames[`alignItems${alignItems}`], classNames[`flexWrap${wrap}`], displayInline && classNames.flexBoxDisplayInline, fitContainer && classNames.fitContainer, className);
const CustomTag = as;
return /*#__PURE__*/_jsx(CustomTag, {
ref: ref,
className: flexBoxClasses,
...rest,
children: children
});
});
FlexBox.displayName = 'FlexBox';
export { FlexBox };