UNPKG

@carbon/react

Version:

React components for the Carbon Design System

58 lines (50 loc) 1.87 kB
/** * 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. */ 'use strict'; 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 _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx); var React__default = /*#__PURE__*/_interopDefaultLegacy(React); var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes); function SkipToContent({ children = 'Skip to main content', className: customClassName, href = '#main-content', tabIndex = 0, ...rest }) { const prefix = usePrefix.usePrefix(); const className = cx__default["default"](`${prefix}--skip-to-content`, customClassName); return /*#__PURE__*/React__default["default"].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__default["default"].string, className: PropTypes__default["default"].string, /** * Provide the `href` to the id of the element on your package that is the * main content. `#main-content` by default. */ href: PropTypes__default["default"].string, /** * Optionally override the default tabindex of 0 */ tabIndex: PropTypes__default["default"].string }; exports["default"] = SkipToContent;