Tailwindcss: Font-family declaration breaks with numbers

Created on 28 Nov 2017  路  4Comments  路  Source: tailwindlabs/tailwindcss

I have a font-family with a number in it, and that breaks the declaration because the fonts aren't wrapped in quotes.

This breaks:

screen shot 2017-11-28 at 09 43 42

Without the number, it works (but that's not my font, so no solution):

screen shot 2017-11-28 at 09 45 07

Quotes would fix it though:

screen shot 2017-11-28 at 09 45 43

Most helpful comment

Hey @sebastiandedeyne! Yeah this is something we considered early on, and considered trying to handle in a magical way, but the rules for when you need quotes around a font are actually quite complex, so instead of spending time trying to solve that in a robust way, we figured it's much easier to just tell people to add quotes if they need quotes.

So in your case, write your config like this:

fonts: {
  sans: ['"DIN 2014"', ...],
  // ...
}

We might make this more automagical down the road, but for now to keep things simple, the rule is "if your values need quotes, add quotes."

All 4 comments

Hey @sebastiandedeyne! Yeah this is something we considered early on, and considered trying to handle in a magical way, but the rules for when you need quotes around a font are actually quite complex, so instead of spending time trying to solve that in a robust way, we figured it's much easier to just tell people to add quotes if they need quotes.

So in your case, write your config like this:

fonts: {
  sans: ['"DIN 2014"', ...],
  // ...
}

We might make this more automagical down the road, but for now to keep things simple, the rule is "if your values need quotes, add quotes."

Makes sense, that's how I solved it for now :)

But why not do it the other way around, and always add quotes?

But why not do it the other way around, and always add quotes?

That would break certain keywords like serif, sans-serif, etc.

We could whitelist those for sure but just seemed like unnecessary magic when we had so much other work to do.

Cool, gonna leave the quotes in my config then, thanks 馃槃

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Tjoosten picture Tjoosten  路  3Comments

jvanbaarsen picture jvanbaarsen  路  3Comments

chintanbanugaria picture chintanbanugaria  路  3Comments

paulhuisman picture paulhuisman  路  3Comments

rgaufman picture rgaufman  路  3Comments