Skip to content

Is this the best way to build typography components? #1527

Answered by jorgeSader
jimburch asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @jimburch, It's been a while since you asked, and I'm not sure if it's even a better approach, but I simply add the tailwind formatting suggested on shadcn's typography to my globals.css file via the "@apply" decorator so that I can keep my semantic OCD in check 😜. Here is what it looks like:

/* Typography */
h1 {
  @apply scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl;
}

h2 {
  @apply scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight transition-colors first:mt-0;
}

h3 {
  @apply scroll-m-20 text-2xl font-semibold tracking-tight;
}

h4 {
  @apply scroll-m-20 text-xl font-semibold tracking-tight;
}

p {
  @apply leading-7 [&:not(:first-child)]:mt-6;
}

b…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@jimburch
Comment options

Comment options

You must be logged in to vote
1 reply
@beMimg
Comment options

Answer selected by jimburch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants