UNPKG

@xgovformbuilder/govuk-react-jsx

Version:

> This package is no longer maintained and will not receive updates bringing it beyond govuk-frontend 4.0.1. If you are using this in your project the simplest way forward is to copy and paste the components from here into your project allowing you to kee

39 lines (32 loc) 1.17 kB
import _extends from "@babel/runtime/helpers/extends"; import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; var _excluded = ["className", "htmlFor", "children", "isPageHeading"]; import React from 'react'; function Label(props) { var className = props.className, htmlFor = props.htmlFor, children = props.children, isPageHeading = props.isPageHeading, attributes = _objectWithoutProperties(props, _excluded); // If no children, just don't output anything if (!children) { return null; } var label = /*#__PURE__*/ // Stop eslint flagging the for/id combination as an error. It is failing due to the way the // input and label are located in different components and so it cannot track the association // // eslint-disable-next-line jsx-a11y/label-has-for React.createElement("label", _extends({ className: "govuk-label ".concat(className || '') }, attributes, { htmlFor: htmlFor }), children); if (isPageHeading === true) { return /*#__PURE__*/React.createElement("h1", { className: "govuk-label-wrapper" }, label); } return label; } export { Label };