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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mohsensami/print

v0.0.1

Published

A simple and powerful React component for printing custom content with full customization capabilities.

Readme

@mohsensami/print

📄 React Print Component

A simple and powerful React component for printing custom content with full customization capabilities.

🚀 Features

  • Simple Integration: Easy to use React component
  • Customizable Styling: Full control over print styles
  • Flexible Content: Print any React content
  • RTL Support: Built-in support for Persian/Arabic content
  • TypeScript: Full TypeScript support
  • Lightweight: Minimal bundle size
  • Customizable Button: Hide button or customize its appearance

📦 Installation

npm install @mohsensami/print
yarn add @mohsensami/print
pnpm add @mohsensami/print

🎯 Quick Start

import React from "react";
import Print from "@mohsensami/print";

function App() {
  return (
    <Print triggerLabel="Print Report">
      <div>
        <h1>Monthly Report</h1>
        <p>This content will be printed</p>
      </div>
    </Print>
  );
}

📚 API Documentation

Props

| Prop | Type | Default | Description | | --------------- | --------------------- | ------------------ | ------------------------- | | children | ReactNode | - | Content to be printed | | triggerLabel | string | "Print" | Print button text | | className | string | "" | CSS class for component | | documentTitle | string | "Print Document" | Document title for print | | pageStyle | string | "" | Custom CSS for print page | | buttonStyle | React.CSSProperties | {} | Print button style | | hideButton | boolean | false | Hide print button |


💡 Usage Examples

Example 1: Simple Print

import Print from "@mohsensami/print";

<Print>
  <div>
    <h1>Document Title</h1>
    <p>Document content</p>
  </div>
</Print>;

Example 2: Print with Custom Styling

<Print
  triggerLabel="Print Report"
  documentTitle="Financial Report"
  pageStyle={`
    body { 
      font-family: 'Arial', sans-serif; 
      direction: ltr; 
      padding: 2rem; 
      line-height: 1.6;
    }
    h1 { 
      color: #2c3e50; 
      border-bottom: 2px solid #3498db;
      padding-bottom: 10px;
    }
    table {
      width: 100%;
      border-collapse: collapse;
      margin: 20px 0;
    }
    th, td {
      border: 1px solid #ddd;
      padding: 8px;
      text-align: left;
    }
    th {
      background-color: #f8f9fa;
    }
  `}
>
  <div>
    <h1>Monthly Financial Report</h1>
    <table>
      <thead>
        <tr>
          <th>Item</th>
          <th>Amount</th>
          <th>Date</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>Income</td>
          <td>$1,000,000</td>
          <td>2024/01/15</td>
        </tr>
        <tr>
          <td>Expenses</td>
          <td>$500,000</td>
          <td>2024/01/20</td>
        </tr>
      </tbody>
    </table>
  </div>
</Print>

Example 3: Print without Button

<Print hideButton={true}>
  <div>Hidden content for printing</div>
</Print>;

// Using ref for programmatic printing
const printRef = useRef();

// Print via code
printRef.current?.printContent();

Example 4: Custom Button

<Print
  triggerLabel="🖨️ Print Invoice"
  buttonStyle={{
    backgroundColor: "#27ae60",
    color: "white",
    border: "none",
    padding: "10px 20px",
    borderRadius: "5px",
    cursor: "pointer",
    fontSize: "14px",
  }}
>
  <div>
    <h1>Sales Invoice</h1>
    {/* Invoice content */}
  </div>
</Print>

🎨 Styling Tips

Recommended Print Styles

/* Base styles for printing */
body {
  font-family: "Arial", "Helvetica", sans-serif;
  direction: ltr;
  line-height: 1.6;
  color: #333;
  margin: 0;
  padding: 20px;
}

/* Headings */
h1,
h2,
h3 {
  color: #2c3e50;
  margin-bottom: 15px;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 15px 0;
}

th,
td {
  border: 1px solid #ddd;
  padding: 8px 12px;
  text-align: left;
}

th {
  background-color: #f8f9fa;
  font-weight: bold;
}

/* Lists */
ul,
ol {
  margin: 10px 0;
  padding-left: 20px;
}

/* Images */
img {
  max-width: 100%;
  height: auto;
}

/* Page breaks */
@media print {
  .no-print {
    display: none !important;
  }

  body {
    margin: 0;
    padding: 15px;
  }
}

🔧 Development

Install Dependencies

npm install

Build Project

npm run build

Run Example

cd example
npm install
npm run dev

📋 Requirements

  • React 17.0.0 or higher
  • React DOM 17.0.0 or higher

🤝 Contributing

To contribute to this project:

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

📄 License

This project is licensed under the MIT License.


🙏 Acknowledgments

  • React Community
  • TypeScript Team
  • Rollup Team

📞 Support

For questions and issues:


⭐ If this project was helpful, please give it a star! ⭐