Skip to content

Instantly share code, notes, and snippets.

@Andy-set-studio
Created February 17, 2020 09:54
Show Gist options
  • Save Andy-set-studio/25eb4e0178d2ce71a9ffefc3c7e87e02 to your computer and use it in GitHub Desktop.
Save Andy-set-studio/25eb4e0178d2ce71a9ffefc3c7e87e02 to your computer and use it in GitHub Desktop.
Heading React Component
import React from 'react'
import PropTypes from 'prop-types'
const Heading = ({children, cssClass, level}) => {
const Tag = `h${level}`
return <Tag className={cssClass}>{children}</Tag>
}
Heading.propTypes = {
children: PropTypes.node.isRequired,
level: PropTypes.number.isRequired,
cssClass: PropTypes.string
}
export default Heading
@Andy-set-studio
Copy link
Author

Usage:

import Heading from './heading.js';

<Heading level={2}>Hello, I am a second level heading</Heading>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment