npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@slalombuild/react-mailto

v0.2.7

Published

react-mailto is a React component library designed to simplify the creation of mailto links with customizable headers and body content. This package allows you to generate fully-featured email links with options for specifying recipients, subject lines, C

Downloads

388

Readme

react-mailto

NPM Version

Overview

react-mailto is a Mailto Link Generator library is a React utility for creating customizable mailto links with optional headers, such as subject, cc, bcc, and body. It also includes components for building the body content of the email with nested lists, line breaks, and indentation.

This package is ideal for developers who want to generate email links with rich content and customizable options directly within their React applications.

Features

  • Create Mailto Links: Easily generate mailto links with multiple recipients, subjects, CCs, and BCCs.
  • Extract Body Content: Parse and format email body content from nested React components.
  • Custom Components: Use components to handle email body formatting with support for indentation, line breaks, and lists.

Installation

Usage

Basic Usage

To create a mailto link with a subject and body content, use the MailTo component. Here's a simple example:

import React from 'react';
import { MailTo, MailToBody, MailToTrigger } from 'package-name';

const App = () => (
  <MailTo to="[email protected]" subject="Hello World">
    <MailToTrigger>Send Email</MailToTrigger>
    <MailToBody>
      Hi there,
      <br />
      This is a test email.
      <br />
      Cheers,
      <br />
      Your Name
    </MailToBody>
  </MailTo>
);

export default App;

Advanced Usage

For more complex scenarios, such as including CC and BCC recipients, or enabling link obfuscation, you can configure the Mailto component accordingly:

import React from 'react';
import { MailTo, MailToBody, MailToTrigger } from 'package-name';

const App = () => (
  <MailTo
    to="[email protected]"
    subject="Meeting Invitation"
    cc={["[email protected]", "[email protected]"]}
    bcc={["[email protected]"]}
    obfuscate
  >
    <MailToTrigger>Invite to Meeting</MailToTrigger>
    <MailToBody>
      Dear Team,
      <br />
      Please join us for a meeting next week.
      <br />
      Regards,
      <br />
      Your Name
    </MailToBody>
  </MailTo>
);

export default App;

Components

MailTo

The main component to generate the mailto link with optional headers and body content.

Props:

  • to (string | string[]): Recipient email addresses.
  • subject (string, optional): Subject of the email.
  • cc (string[] | string, optional): CC recipients.
  • bcc (string[] | string, optional): BCC recipients.
  • obfuscate (boolean, optional): Whether to obfuscate the mailto link.
  • children (React.ReactNode): Content to be rendered inside the link.

MailToBody

A component to define the body content of the email.

Props:

  • children (React.ReactNode): Content to include in the email body.

MailToTrigger

A component that renders a clickable link to trigger the mailto action.

Props:

  • children (React.ReactNode): The text or elements to display inside the link.
  • props (React.AnchorHTMLAttributes<HTMLAnchorElement>, optional): Additional props for the anchor element.

MailToIndent

A component to add indentation in the email body content.

Props:

  • children (React.ReactNode): Content to include with indentation.
  • spacing (number, optional): Number of spaces for indentation.

MailToBreak

A component to insert line breaks in the email body content.

Props:

  • spacing (number, optional): Number of line breaks.

Contributing

We welcome contributions! If you want to help improve this package:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature/your-feature).
  3. Commit your changes (git commit -am 'Add new feature').
  4. Push to the branch (git push origin feature/your-feature).
  5. Create a Pull Request.

For more details, check our contributing guidelines.

License

This project is licensed under the MIT License.

Thank you for using react-mailto!