Why this setup is needed
Tailwind CSS uses a JIT (Just-In-Time) compiler that scans your source files to determine which classes to generate. Since the toast components are installed as npm packages innode_modules, Tailwind won’t scan them by default.
Without this configuration, the toast components won’t be styled correctly because Tailwind won’t generate the necessary CSS classes.
Tailwind v4 setup
If you’re using Tailwind CSS v4, add a@source directive to your main CSS file.
- Vue 3
- React
Add this line to your
resources/css/app.css file:resources/css/app.css
The relative path
../../node_modules/ assumes your CSS file is at resources/css/app.css. If your CSS file is in a different location, adjust the path accordingly.Multiple CSS file locations
If your CSS file is in a different location, adjust the relative path:app/frontend/styles/app.css (example)
public/css/app.css (example)
Tailwind v3 setup
If you’re using Tailwind CSS v3, add the package path to thecontent array in your Tailwind configuration.
- Vue 3
- React
tailwind.config.js
The paths above assume your
tailwind.config.js is at the root of your project. The paths are relative to where the config file is located.TypeScript config files
If you’re usingtailwind.config.ts instead:
Verifying the setup
After configuring Tailwind, rebuild your assets:Common issues
Toasts appear unstyled
Cause: Tailwind isn’t detecting the classes used by the toast components. Solution:- Verify you’ve added the correct path to your Tailwind config
- Rebuild your assets with
npm run buildor restartnpm run dev - Clear your browser cache
Wrong relative path
Cause: The relative path in your config doesn’t correctly point tonode_modules.
Solution: Adjust the path based on where your config file is located:
- If config is at project root:
./node_modules/@laravel-inertia-toast/... - If CSS is in
resources/css/:../../node_modules/@laravel-inertia-toast/... - If CSS is in a nested folder: Count directories up to reach project root
Both Vue and React packages
Cause: You accidentally added both packages to your config. Solution: Only include the package for the framework you’re using:- Use
@laravel-inertia-toast/vuefor Vue 3 projects - Use
@laravel-inertia-toast/reactfor React projects - Never include both (unless you’re building a multi-framework setup, which is rare)