Wave - how to change default font to a Google font?

Solved
droenfeldt

Nov 12th, 2024 04:34 AM

I'm getting more and more fascinated by Wave and how powerfully customizable it is.

However, I've been trying to figure out how to replace the default (kinda boring) font to a webfont provided by Google Fonts, say, "Exo 2".

Any suggestions on how I could achieve this would be greatly appreciated.

LE: I believe it's worth mentioning the fact that I already added a Google font to Filament, according to the Filament official docs, by adding ->font('Exo 2', provider: GoogleFontProvider::class) to the $panel configuration in app/Providers/Filament/AdminPanelProvider.php.

bobbyiliev

Nov 12th, 2024 05:45 AM

Best Answer

Hey Daniel!

Great to hear you're enjoying Wave! 🚀

If you've already set up Google Fonts in Filament using GoogleFontProvider, that's great! However, if you want to replace the default font across your entire Wave app (including non-Filament areas), here's how you can do it:

Step 1: Add the Google Font to Your Theme's app.css

Open your main CSS file, typically located at /resources/themes/anchor/assets/css/app.css, or the app.css file of the theme that you are using, and import the Google font at the top:

@import url('https://fonts.googleapis.com/css2?family=Exo+2:wght@400;700&display=swap');

Step 2: Update the Tailwind Configuration

To ensure that the Google font is used throughout your Wave project, you'll need to update your Tailwind CSS configuration file, usually located at tailwind.config.js.

Edit the file to include your new font:

module.exports = {
    theme: {
        extend: {
            fontFamily: {
                sans: ['"Exo 2"', 'sans-serif'], // Add your Google font here
            },
        },
    },
    plugins: [],
};

Step 3: Apply the New Font Globally

In your /resources/themes/anchor/assets/css/app.css, update the base styles to use the new font:

body {
    font-family: 'Exo 2', sans-serif;
}

Step 4: Compile Your Assets

Now, run the following command to compile your assets using Vite:

npm run dev

Or, for production:

npm run build

If you're not seeing the changes, try clearing your browser cache or running:

php artisan optimize:clear

This is the standard way of making any CSS/JS related changes in Wave and any Laravel project that uses Vite.

Let me know if that works for you!

- Bobby

Report
1
droenfeldt

Nov 12th, 2024 10:03 AM

Hey Bobby,

For some reason I tend to forget that Wave is built on top of Laravel, and therefore such customizations should be made at the "Laravel level" :D

That being said, I appreciate your fast, kind, and insightful solution. It turned out that Step 3 wasn't necessary, since the new font got automatically registered as the framework's sans font and got applied throughout the entire Wave app, which is what I needed.

Once again, many thanks for your help.

Report
1
bobbyiliev

Nov 13th, 2024 12:51 AM

Hey!

No worries at all! Happy to help!

Good luck with your project.

- Bobby

Report
1