UNPKG

ghg-react

Version:

A library of React components for my own use.

34 lines (28 loc) 743 B
import React from 'react'; import PropTypes from 'prop-types'; /** Label with required field display, htmlFor, and block styling */ var Label = function Label(_ref) { var htmlFor = _ref.htmlFor, label = _ref.label, required = _ref.required; return React.createElement( 'label', { style: { display: 'block' }, htmlFor: htmlFor }, label, ' ', required && React.createElement( 'span', { style: { color: 'red' } }, ' *' ) ); }; Label.propTypes = { /** HTML ID for associated input */ htmlFor: PropTypes.string.isRequired, /** Label text */ label: PropTypes.string.isRequired, /** Display asterisk after label if true */ required: PropTypes.bool }; export default Label;