diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-03-31 15:39:55 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-03-31 15:46:54 +0200 |
| commit | 8370602f37ad6aa02485d85e5b179b76c3f15701 (patch) | |
| tree | 5a92ac70db1f791aae19a67b92da356c9ed4ed5a /src/components/atoms/headings/heading.tsx | |
| parent | 351532e9906e32c862bf6810a3871993cde13ba2 (diff) | |
chore: add a Heading component
Diffstat (limited to 'src/components/atoms/headings/heading.tsx')
| -rw-r--r-- | src/components/atoms/headings/heading.tsx | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/components/atoms/headings/heading.tsx b/src/components/atoms/headings/heading.tsx new file mode 100644 index 0000000..1535140 --- /dev/null +++ b/src/components/atoms/headings/heading.tsx @@ -0,0 +1,21 @@ +import { FC } from 'react'; + +type HeadingProps = { + /** + * HTML heading level: 'h1', 'h2', 'h3', 'h4', 'h5' or 'h6'. + */ + level: 1 | 2 | 3 | 4 | 5 | 6; +}; + +/** + * Heading component. + * + * Render an HTML heading element. + */ +const Heading: FC<HeadingProps> = ({ children, level }) => { + const TitleTag = `h${level}` as keyof JSX.IntrinsicElements; + + return <TitleTag>{children}</TitleTag>; +}; + +export default Heading; |
