numeric-title
v1.0.0
Published
A React component that dynamically renders heading tags (h1-h6) based on a numeric prop with paragraph fallback.
Maintainers
Readme
NumericTitle Component
A simple React component that renders headings (h1 to h6) based on a numeric input, with a fallback to a paragraph tag.
Installation
You can install numeric-title via npm:
npm install numeric-titleor using yarn:
yarn add numeric-titleUsage
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>
</>
);
}Props
n(number, optional): Determines heading level (1-6)1renders<h1>2renders<h2>3renders<h3>4renders<h4>5renders<h5>6renders<h6>- Any other value or undefined renders
<p>
children(any, optional): Content to be rendered inside the heading element
Behavior
The component will render:
- The appropriate heading tag (
h1throughh6) whennis between 1-6 - A paragraph tag (
p) in all other cases (whennis undefined or not 1-6)
