Using Tailwind | laravel-pdf | Spatie

 SPATIE

  Laravel PDF
==============

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-pdf](https://spatie.be/docs/laravel-pdf/v1)  Advanced-usage  Using Tailwind

 Version   v2   v1

 Other versions for crawler [v2](https://spatie.be/docs/laravel-pdf/v2) [v1](https://spatie.be/docs/laravel-pdf/v1)

  Using Tailwind
- [ Introduction ](https://spatie.be/docs/laravel-pdf/v1/introduction)
- [ Support us ](https://spatie.be/docs/laravel-pdf/v1/support-us)
- [ Requirements ](https://spatie.be/docs/laravel-pdf/v1/requirements)
- [ Installation &amp; setup ](https://spatie.be/docs/laravel-pdf/v1/installation-setup)
- [ Questions and issues ](https://spatie.be/docs/laravel-pdf/v1/questions-issues)
- [ Alternatives ](https://spatie.be/docs/laravel-pdf/v1/alternatives)
- [ Changelog ](https://spatie.be/docs/laravel-pdf/v1/changelog)
- [ About us ](https://spatie.be/docs/laravel-pdf/v1/about-us)

Basic usage
-----------

- [ Creating PDFs ](https://spatie.be/docs/laravel-pdf/v1/basic-usage/creating-pdfs)
- [ Responding with PDFs ](https://spatie.be/docs/laravel-pdf/v1/basic-usage/responding-with-pdfs)
- [ Formatting PDFs ](https://spatie.be/docs/laravel-pdf/v1/basic-usage/formatting-pdfs)
- [ Saving PDFs to disks ](https://spatie.be/docs/laravel-pdf/v1/basic-usage/saving-pdfs-to-disks)
- [ Testing PDFs ](https://spatie.be/docs/laravel-pdf/v1/basic-usage/testing-pdfs)
- [ Setting defaults ](https://spatie.be/docs/laravel-pdf/v1/basic-usage/setting-defaults)

Advanced usage
--------------

- [ Configuration ](https://spatie.be/docs/laravel-pdf/v1/advanced-usage/configuration)
- [ Creating PDFs with multiple pages ](https://spatie.be/docs/laravel-pdf/v1/advanced-usage/creating-pdfs-with-multiple-pages)
- [ Customizing Browsershot ](https://spatie.be/docs/laravel-pdf/v1/advanced-usage/customizing-browsershot)
- [ Generating PDFs on AWS Lambda ](https://spatie.be/docs/laravel-pdf/v1/advanced-usage/generating-pdfs-on-aws-lambda)
- [ Using Tailwind ](https://spatie.be/docs/laravel-pdf/v1/advanced-usage/using-tailwind)
- [ Extending with Macros ](https://spatie.be/docs/laravel-pdf/v1/advanced-usage/extending-with-macros)

      You are viewing the documentation for **an older version** of this package. You can check the version you are using with the following command:

 `                                    composer show spatie/laravel-pdf                                                                                                                                                                                                                                    `

Using Tailwind
==============

You can use Tailwind to style your PDFs. This is a great way to create PDFs that look great. Let's create a beautiful PDF invoice using Tailwind.

In your project, you need to save a Blade view with content like this. In this view, we use the CDN version of Tailwind (in your project you can use an asset built with Vite) and got an invoice layout from one of the many Tailwind template sites.

```

    Invoice

            Your Company Name

            Invoice
            Date: 01/05/2023
            Invoice #: {{ $invoiceNumber }}

        Bill To:
        {{ $customerName }}
        123 Main St.
        Anytown, USA 12345
        johndoe@example.com

            Description
            Quantity
            Price
            Total

            Product 1
            1
            $100.00
            $100.00

            Product 2
            2
            $50.00
            $100.00

            Product 3
            3
            $75.00
            $225.00

        Subtotal:
        $425.00

        Tax:
        $25.50

        Total:
        $450.50

        Payment is due within 30 days. Late payments are subject to fees.
        Please make checks payable to Your Company Name and mail to:
        123 Main St., Anytown, USA 12345

```

In your app, you can add a controller like this. The above view is saved in `resources/views/pdf/invoice`.

```
namespace App\Http\Controllers;

use function Spatie\LaravelPdf\Support\pdf;

class DownloadInvoiceController
{
    public function __invoke()
    {
        return pdf('pdf.invoice', [
            'invoiceNumber' => '1234',
            'customerName' => 'Grumpy Cat',
        ]);
    }
}
```

When you hit that controller, a formatted PDF will be downloaded.

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
