UNPKG

@carbon/react

Version:

React components for the Carbon Design System

51 lines (49 loc) 1.54 kB
/** * Copyright IBM Corp. 2016, 2026 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. */ import { usePrefix } from "../../internal/usePrefix.js"; import { GridSettings } from "./GridContext.js"; import classNames from "classnames"; import React from "react"; import PropTypes from "prop-types"; import { jsx } from "react/jsx-runtime"; //#region src/components/Grid/FlexGrid.tsx /** * Copyright IBM Corp. 2016, 2023 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. */ const FlexGrid = React.forwardRef(({ as, condensed = false, narrow = false, fullWidth = false, className: containerClassName, children, ...rest }, ref) => { const prefix = usePrefix(); const className = classNames(containerClassName, { [`${prefix}--grid`]: true, [`${prefix}--grid--condensed`]: condensed, [`${prefix}--grid--narrow`]: narrow, [`${prefix}--grid--full-width`]: fullWidth }); return /* @__PURE__ */ jsx(GridSettings, { mode: "flexbox", subgrid: false, children: /* @__PURE__ */ jsx(as || "div", { className, ref, ...rest, children }) }); }); FlexGrid.propTypes = { as: PropTypes.oneOfType([PropTypes.string, PropTypes.elementType]), children: PropTypes.node, className: PropTypes.string, condensed: PropTypes.bool, fullWidth: PropTypes.bool, narrow: PropTypes.bool }; const FlexGridComponent = FlexGrid; //#endregion export { FlexGridComponent };