One data grid for JavaScript, React, Vue & Angular. Sorting, filtering, virtualization, pinning, and CSV export included. Early access $199 $349 → [Get it now]

How to print tables in React

Adding print functionality to tables allows users to create physical or PDF copies of data, which is crucial for reports and documentation. As the creator of CoreUI, I’ve implemented print features in numerous enterprise systems. The most effective solution is to use the browser’s native print dialog combined with CSS print media queries to control what gets printed. This approach requires no external libraries and works across all modern browsers.

Use window.print() combined with CSS @media print to create a print-friendly table view.

const PrintableTable = ({ data }) => {
  const handlePrint = () => {
    window.print()
  }

  return (
    <div>
      <button onClick={handlePrint} className='no-print'>Print Table</button>
      <table className='printable-table'>
        <thead>
          <tr>
            <th>Name</th>
            <th>Email</th>
          </tr>
        </thead>
        <tbody>
          {data.map((row, i) => (
            <tr key={i}>
              <td>{row.name}</td>
              <td>{row.email}</td>
            </tr>
          ))}
        </tbody>
      </table>
    </div>
  )
}

Add this CSS to your stylesheet:

@media print {
  .no-print {
    display: none;
  }

  .printable-table {
    width: 100%;
    border-collapse: collapse;
  }

  .printable-table th,
  .printable-table td {
    border: 1px solid #000;
    padding: 8px;
  }
}

Best Practice Note

The window.print() function triggers the browser’s print dialog. The @media print CSS rule hides the print button and applies print-specific styles like borders and padding. You can hide navigation, sidebars, and other UI elements by adding the no-print class. This is the same pattern we use in CoreUI admin templates to ensure clean, professional printed reports without unnecessary page elements.


Speed up your responsive apps and websites with fully-featured, ready-to-use open-source admin panel templates—free to use and built for efficiency.


About the Author

Subscribe to our newsletter
Get early information about new products, product updates and blog posts.
How to Merge Objects in JavaScript
How to Merge Objects in JavaScript

How to round a number to two decimal places in JavaScript
How to round a number to two decimal places in JavaScript

How to check if a string is a number in JavaScript
How to check if a string is a number in JavaScript

How to check if an array is empty in JavaScript?
How to check if an array is empty in JavaScript?

Answers by CoreUI Core Team