A simple React component that renders headings (h1
to h6
) based on a numeric input, with a fallback to a paragraph tag.
You can install numeric-title via npm:
npm install numeric-title
or using yarn:
yarn add numeric-title
import { NumericTitle } from 'numeric-title';
function MyComponent() {
return (
<>
<NumericTitle n={1}>This will be an h1</NumericTitle>
<NumericTitle n={3}>This will be an h3</NumericTitle>
<NumericTitle>This will be a paragraph (default)</NumericTitle>
</>
);
}
-
n
(number, optional): Determines heading level (1-6)-
1
renders<h1>
-
2
renders<h2>
-
3
renders<h3>
-
4
renders<h4>
-
5
renders<h5>
-
6
renders<h6>
- Any other value or undefined renders
<p>
-
-
children
(any, optional): Content to be rendered inside the heading element
The component will render:
- The appropriate heading tag (
h1
throughh6
) whenn
is between 1-6 - A paragraph tag (
p
) in all other cases (whenn
is undefined or not 1-6)