0.0.8 • Published 9 months ago

react-autolink-heading v0.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

React AutolinkHeading

npm package Downloads Issues

AutolinkHeading is a React component that enhances your headings with automatic anchor links, making navigation within long documents a breeze.

Just like rehype-autolink-headings but for React.

Features

  • Automatically generates anchor links for headings.
  • Customizable class names and ARIA labels.
  • Works with various levels of headings (h1 - h6).
  • Lightweight and easy to integrate.

Install

Install the package via npm:

npm install react-autolink-heading

or pnpm

pnpm i react-autolink-heading

Usage

import React from 'react';
import { AutolinkHeading } from 'autolink-heading';

function MyComponent() {
  return (
    <div>
      <AutolinkHeading className="my-heading" linkClassName="my-link">
        <h2>My Header Title</h2>
      </AutolinkHeading>
      {/* Add more AutolinkHeading components as needed */}
    </div>
  );

Props

PropTypeDescription
childrenReactNodeThe heading element(s) to enhance with anchor links.
classNamestringAdditional class name(s) for the heading element.
linkClassNamestringAdditional class name(s) for the anchor link.
ariaLabelstringARIA label for the anchor link (default: 'Link to section').
headingIdstringManually set the heading ID for the anchor link.

License

This project is licensed under the MIT License.


If you find AutolinkHeading helpful, consider giving it a ⭐️ on GitHub!

0.0.8

9 months ago

0.0.7

9 months ago

0.0.6

9 months ago

0.0.5

9 months ago

1.0.0

9 months ago