Тёмный

How to Use Custom Fonts with Tailwind CSS 

Tailwind Labs
Подписаться 95 тыс.
Просмотров 75 тыс.
50% 1

In this video, I'll show you how to use custom fonts in your Tailwind CSS project. We'll look into embedding Google Fonts, as well as self-hosting fonts using the @font-face CSS at-rule.
Documentation: tailwindcss.co...
Source code: play.tailwindc...

Опубликовано:

 

13 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 105   
@KingOfCorinth
@KingOfCorinth 3 года назад
For that one person who is under a time crunch Embedding Google Fonts: 0:37 Self Hosted Fonts: 7:22
@user-vj3cu3wv9l
@user-vj3cu3wv9l 2 года назад
life saver bro
@davidluhr
@davidluhr 3 года назад
Another great video, Simon! Bonus tip: use `font-display: swap;` in your `@font-face` declarations for a performance boost. This allows the browser to render first paint more quickly by displaying the system font as soon as possible, and then "swapping" to your custom fonts once they become available. It prevents the infamous FOUT (Flash of Unstyled Text) 😉
@simonswiss
@simonswiss 3 года назад
Totally, that would have been a great addition to this video 👍
@robyroby162
@robyroby162 3 года назад
Actually this brings FOUT back by design!
@davidluhr
@davidluhr 3 года назад
@@robyroby162 Sorry, I meant FOIT (Flash of Invisible Text). Thanks for correcting me!
@hmatpin
@hmatpin 3 года назад
Man, thanks for not monetizing this great channel
@codenameunknown3791
@codenameunknown3791 3 года назад
8:13 looool. Big shoutout to Mr. Wes Bos out there.
@simonswiss
@simonswiss 3 года назад
Haha I was waiting for those comments 😅
@pedromartindelcampogonzale9613
@pedromartindelcampogonzale9613 3 года назад
Your vídeos are really uplifting, love your attitude.
@mohabedr5030
@mohabedr5030 3 года назад
Tailwind is the future
@Max-xp3tf
@Max-xp3tf 3 года назад
The future is Tailwind *
@81NARY
@81NARY 3 года назад
And the future is now!
@Max-xp3tf
@Max-xp3tf 3 года назад
@@81NARY 👀
@nitro4109
@nitro4109 2 года назад
And I'm from future
@kayf7073
@kayf7073 3 года назад
Great. Remember, when your website is also seen by people living in europe, including files from external sources like google is against eu gdpr law, because it transfers personal data (ip adesss) to other parties (worst of all: in the us) without prior consent. So selfhosting fonts, scripts, images etc is the only way to go
@moracabanas
@moracabanas 3 года назад
I cannot believe this thing wth is going on laws...
@JimOHalloran
@JimOHalloran 3 года назад
Woohoo! Simon is winning at CSS and Year 4 Miniball! Division 1 no less!
@oliverye55
@oliverye55 2 года назад
Amazing video! super direct and to the point!! love this.
@saschamajewsky7990
@saschamajewsky7990 3 года назад
When Tailwind CSS Merch?
@ruslansteiger
@ruslansteiger 3 года назад
Primus Utilitatem
@moracabanas
@moracabanas 3 года назад
If you import fonts with @import and extend your tailwind.config.js you must rebuild. HMR just won't apply that font until you Ctrl + c your Node terminal. It took me 3h to point that. At least using windicss
@melissawhite7522
@melissawhite7522 2 года назад
Learning Tailwindcss and just wanted to say thanks for the reminder. Was totally like "why ins't this working." and forgot the rebuild. :)
@shivankbatra5643
@shivankbatra5643 Год назад
thanks a lot man, 5hr for me to be precise and was about to give up before I saw this comment. Feeling really stupid but finally it works!
@yassminh
@yassminh Год назад
This comment should be pinned. You have saved me from wasting hours trying to figure out why it didn't work. Thank you!
@The_Penny_Seventeens
@The_Penny_Seventeens 7 месяцев назад
Thank you my website is one step closer!
@christyjacob8551
@christyjacob8551 3 года назад
I just googled for this yesterday!!
@kelas-frontend
@kelas-frontend 3 года назад
Yeah, me too 😁
@RobertWildling
@RobertWildling Год назад
Great and important video! - I Austria there is a weird law case going on, where a woman accuses more than 1000 website owners of not having been explicit enough about their Google Font implementation. She feels that here private data has been exposed. The case is not yet over, but it shows that it might be a good idea to self-host google fonts...
@en3rr
@en3rr Год назад
Thanks this helps a lot!
@lautaroriveiro
@lautaroriveiro 2 года назад
Thanks again!
@YazinS
@YazinS 3 года назад
Great video! I was hoping it would cover how to change the default body font? I don't see a class (e.g. font-body) that can be overridden?
@justinoneill2837
@justinoneill2837 2 года назад
I'm trying to add a custom icon font library w/ this method (material design icons to be exact). it's acting a tad bit strange though. Would be cool to see another video on how Tailwind recommends doing this.
@cas4425
@cas4425 3 года назад
🔥🔥🔥
@edanbenatar
@edanbenatar 2 года назад
Would you have to define all the weight classes so that Tailwind behaves accordingly with the font weight utility classes?
@probelou
@probelou 2 года назад
If I have the one font with multiple weights and want to use the tw font-weight utility classes how do I declare that? E.g. class="font-fontName font-weight-normal" or class="font-fontName font-weight-bold". I tried this but the cascade wins so `fontName` uses 700 weight irrespective of the weight utility class. @font-face { font-family: "fontName"; font-weight: 400; src: url("../public/fonts/font-name-400.woff2") format("woff2"), url("../public/fonts/font-name-400.woff") format("woff"); } @font-face { font-family: "fontName"; font-weight: 700; src: url("../public/fonts/font-name-700.woff2") format("woff2"), url("../public/fonts/font-name-700.woff") format("woff"); }
@oliverye55
@oliverye55 2 года назад
Subscribed and liked!!
@ICOReviewtoken
@ICOReviewtoken Год назад
Hi bro. I have a custom font that I want to import locally but it doesn't accept it. Also if I want to give users the ability to choose their own fonts when using, for example users will set the font for different title tags and font base, can I do it in nextjs 13? Please give me solution. I use nextjs 13, taiwincss. Thank you
@mike110111
@mike110111 3 года назад
Please can you do a video explaining css layout for beginners
@BneiAnusim
@BneiAnusim Год назад
PRICELESS! Thanks 😉
@mattd5419
@mattd5419 3 года назад
how can we use variable fonts?
@CARUSAR21
@CARUSAR21 3 года назад
So epic once again.
@codeative
@codeative 3 года назад
just awesome
@joshuarileymagic
@joshuarileymagic 2 года назад
I maybe thinking too advanced or might not be performant but since the JIT compiler CDN is JS and you can use [ ] in classes, wouldn't it be easier if the CDN auto-imported the google font if you use say font-[Roboto] then it'll auto import the font as a link tag in header and dynamically create the css needed, just an idea anyway :) I'm starting to look more into customising Tailwind after using the defaults for a while along with custom css
@abdullahialhassan3700
@abdullahialhassan3700 3 года назад
I have a question, while you are using the jit kit fo you need a css folder too
@momenabdelghafar7771
@momenabdelghafar7771 3 года назад
what is font-family in the text-editor
@HosamHasanMonir
@HosamHasanMonir 3 года назад
monolisa font
@anirudh1713
@anirudh1713 3 года назад
Its DankMono, its paid.
@modz9711
@modz9711 3 года назад
@@anirudh1713 yup it's dank mono..! Check the 'f' its unique ..!
@marcorieser
@marcorieser 3 года назад
I think it's MonoLisa, they released version 1.8 yesterday which adds a script variant that gives you a similar look like Dank Mono.
@modz9711
@modz9711 3 года назад
@@marcorieser will check it
@tomrowe2181
@tomrowe2181 3 года назад
Would have liked a V2.2 example of this in the video! I had to work it out myself the other day 😅 Moving off CSS files was a game changer, but the docs are missing a lot of examples on how to customise certain things
@TailwindLabs
@TailwindLabs 3 года назад
This example was made in 2.2! The exact same technique has been working since v1 by the way, there is nothing different about adding custom fonts to Tailwind since version 2.2.
@tomrowe2181
@tomrowe2181 3 года назад
@@TailwindLabs Oh I meant without CSS files! 😅 By defining font-faces in a custom plugin for the tailwind config
@muskanbhatnagar7535
@muskanbhatnagar7535 Год назад
Hi, is there a possibility to conditionally add a font? I have a multitenant setup, and for different client UI's, we support client specific fonts. In client A's app, I only use client A's font. But embedding fonts this way downloads client B's font as well even though it is not used.
@DrHappybone
@DrHappybone 3 года назад
Can't get local fonts to load at all.. just flat out refusing to do it. Using Vite, npm run dev for the server and tried using public file in root. No matter what I do, it's not loading the fonts
@rickdev1922
@rickdev1922 3 года назад
me too😢
@adeema664
@adeema664 Год назад
very good video 🥰🥰
@govindsaini8085
@govindsaini8085 3 года назад
Hi I m facing the pb of display I want to show in lg screen of image and mobile devices I want to show hidden of image "hidden md:block " I used but doesn't work show this kind of pb how to solve if possible as soon as reply for this question
@jobsphil9553
@jobsphil9553 3 года назад
I wish you provide html source together. I wonder how the regular / bold font applied to css.
@nbbhaskar3294
@nbbhaskar3294 3 года назад
Either font-bold tailwind class can be added to your html element. Or in @font-face declaration in your css file, you can specify font-weight: 700 and point src to the bold font file, that should it.
@TheKumarAshwin
@TheKumarAshwin 2 года назад
how to avoid expected behaviour issue, as my custome fonts loads after the default font?
@varun_y
@varun_y 3 года назад
when using with nextjs and self hosted fonts , i had to put link in head tag as well.
@OneBrokeBloke
@OneBrokeBloke Год назад
And local fonts, but as utility classes? Thats what im looking for
@irving7653
@irving7653 Год назад
What are the font and theme you use?
@lawrencemotions8720
@lawrencemotions8720 2 года назад
How to add fonts in next js.
@JamisIcon
@JamisIcon 2 года назад
Hi, thanks for the great tips, I'm kinda new to this, my font changed when I added it to the app.css file not the tailwind.config.js, I'm kind of wondering what happened :D
@nozimjonjuraev2666
@nozimjonjuraev2666 Год назад
can anyone tell me how to set up truetype font in project with tailwindcss?
@ch3tankate469
@ch3tankate469 3 года назад
We want more such videos Plz reply this post if you want more
@hmatpin
@hmatpin 3 года назад
Hi. Does anybody know how to include the css of a third party library like slick slider into a tailwind project?
@waldothedev
@waldothedev 3 года назад
Haha, amazing...how do you say that again Wes? vit? veet? lol
@esdev
@esdev 3 года назад
Is it possible to use without tailwind config file , more preciously in new tailwind cli jit mode which doesn't require config file??
@simonswiss
@simonswiss 3 года назад
If you want a custom "font-${fontName}" utility class, you'll need a Tailwind config file. You can still use a custom font and set it in CSS on the HTML elements you want to target.
@aaymankhalid9997
@aaymankhalid9997 Год назад
I need to know the vscode theme being used in this video🙃
@simonswiss
@simonswiss Год назад
The theme is Night Owl, and the font is Dank Mono ✨
@phonghoanggia9181
@phonghoanggia9181 3 года назад
I just wanna know what font do u use in your text editor?
@alessandro2092
@alessandro2092 2 года назад
Dank Mono
@Ravi0207
@Ravi0207 Год назад
Anyone struggling with using the next font optimisation with tailwind - In _app file declare the font as a jsx style css variable. And use that variable in the tailwind config file
@TheCrisisCall
@TheCrisisCall 3 года назад
Really very good video! I'll start implementing the fonts this way. On the other hand, does anyone know how to include style that should be in regardless of whether their classes are in the HTML or not? It happens that I apply style to a carousel but it only exists when the page loads, so the purged css does not contain the style
@guilhermeeduardomaffei1247
@guilhermeeduardomaffei1247 2 года назад
which font do you use in Visual Code ?
@janascofield
@janascofield 2 года назад
operator mono
@bogdanlupu3679
@bogdanlupu3679 3 года назад
From what Tailwindcss version does this work? Does it work in 2.0 or 2.2 onwards?
@wobsoriano
@wobsoriano 3 года назад
Since v1
@simonswiss
@simonswiss 3 года назад
It was already working in v1, we just haven't provided many examples until now 👍
@bogdanlupu3679
@bogdanlupu3679 3 года назад
@@simonswiss thanks. I am new on tailwind and i plan to use in a project that nas custom fonts. The codebase vad installed 2.0. That's why the question. Thanks again for the answer.
@mychoppaeat
@mychoppaeat Год назад
1:00 eyo!
@esdev
@esdev 3 года назад
Sweet 😎
@Keteku.
@Keteku. 2 года назад
What font is he using in his code editor ? Any help here
@janascofield
@janascofield 2 года назад
operator mono
@Keteku.
@Keteku. 2 года назад
@@janascofield Will check it out. Huge thanks
@sherifsaleh111
@sherifsaleh111 3 года назад
What's the text editor font are you using 🙏?
@alessandro2092
@alessandro2092 2 года назад
Dank Mono
@mikefenn2451
@mikefenn2451 11 месяцев назад
8:15
@parth.dobariya
@parth.dobariya Год назад
0:53 tujhe malum hai tu kya bolra hai😂
@vic_casanas
@vic_casanas 3 года назад
First
@haridass2208
@haridass2208 3 года назад
Bye bye bootstrap 🤣
@shaungbhone8368
@shaungbhone8368 3 года назад
Beet
Далее
Theming Tailwind with CSS Variables
27:24
Просмотров 124 тыс.
How Strong is Tin Foil? 💪
00:26
Просмотров 48 млн
Translating a Custom Design System to Tailwind CSS
10:10
Rebuilding iOS 15 with Tailwind CSS
20:19
Просмотров 76 тыс.
These font stacks will improve your site performance
11:44
I WISH I Knew These Tailwind Tips Earlier
9:15
Просмотров 186 тыс.
Styling Forms with Tailwind CSS
17:25
Просмотров 141 тыс.
10 Tailwind Classes I Wish I Knew Earlier
13:31
Просмотров 183 тыс.
How to host your own fonts made simple
14:00
Просмотров 91 тыс.
What's New in Tailwind CSS v2.2
21:21
Просмотров 51 тыс.