@carbon/react
Version:
React components for the Carbon Design System
60 lines (56 loc) • 1.73 kB
JavaScript
/**
* 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.
*/
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
import cx from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
import { usePrefix } from '../../internal/usePrefix.js';
function Row({
as: BaseComponent = 'div',
condensed = false,
narrow = false,
className: containerClassName,
children,
...rest
}) {
const prefix = usePrefix();
const className = cx(containerClassName, {
[`${prefix}--row`]: true,
[`${prefix}--row--condensed`]: condensed,
[`${prefix}--row--narrow`]: narrow
});
// TypeScript type validation reports conflicts on different instances of keyof JSX.IntrinsicElements
const BaseComponentAsAny = BaseComponent;
return /*#__PURE__*/React.createElement(BaseComponentAsAny, _extends({
className: className
}, rest), children);
}
Row.propTypes = {
/**
* Provide a custom element to render instead of the default <div>
*/
as: PropTypes.oneOfType([PropTypes.string, PropTypes.elementType]),
/**
* Pass in content that will be rendered within the `Row`
*/
children: PropTypes.node,
/**
* Specify a custom className to be applied to the `Row`
*/
className: PropTypes.string,
/**
* Specify a single row as condensed.Rows that are adjacent
* and are condensed will have 2px of margin between them to match gutter.
*/
condensed: PropTypes.bool,
/**
* Specify a single row as narrow. The container will hang
* 16px into the gutter.
*/
narrow: PropTypes.bool
};
export { Row as default };