@carbon/react
Version:
React components for the Carbon Design System
52 lines (46 loc) • 1.43 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.
*/
;
Object.defineProperty(exports, '__esModule', { value: true });
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
var cx = require('classnames');
var React = require('react');
var PropTypes = require('prop-types');
var usePrefix = require('../../internal/usePrefix.js');
function SkipToContent({
children = 'Skip to main content',
className: customClassName,
href = '#main-content',
tabIndex = 0,
...rest
}) {
const prefix = usePrefix.usePrefix();
const className = cx(`${prefix}--skip-to-content`, customClassName);
return /*#__PURE__*/React.createElement("a", _rollupPluginBabelHelpers.extends({}, rest, {
className: className,
href: href,
tabIndex: tabIndex
}), children);
}
SkipToContent.propTypes = {
/**
* A ReactNode to display in the SkipToContent `a` tag.
* `'Skip to main content'` by default.
*/
children: PropTypes.string,
className: PropTypes.string,
/**
* Provide the `href` to the id of the element on your package that is the
* main content. `#main-content` by default.
*/
href: PropTypes.string,
/**
* Optionally override the default tabindex of 0
*/
tabIndex: PropTypes.string
};
exports.default = SkipToContent;