Skip to content

Instantly share code, notes, and snippets.

@travyyx
Created June 19, 2024 22:09
Show Gist options
  • Save travyyx/c8ef4d52421ec81712a22a0b2c9461ff to your computer and use it in GitHub Desktop.
Save travyyx/c8ef4d52421ec81712a22a0b2c9461ff to your computer and use it in GitHub Desktop.
A shadcn ui typography file for heading and paragraphs
import React from 'react';
interface Props {
className?: string;
children: string;
}
const H1: React.FC<Props> = ({className, children}) => {
return (
<h1 className={`scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl ${className}`}>
{children}
</h1>
)
}
const H2: React.FC<Props> = ({className, children}) => {
return (
<h2 className={`scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight first:mt-0 ${className}`}>
{children}
</h2>
)
}
const H3: React.FC<Props> = ({className, children}) => {
return (
<h3 className={`scroll-m-20 text-2xl font-semibold tracking-tight ${className}`}>
{children}
</h3>
)
}
const H4: React.FC<Props> = ({className, children}) => {
return (
<h4 className={`scroll-m-20 text-xl font-semibold tracking-tight ${className}`}>
{children}
</h4>
)
}
const P: React.FC<Props> = ({className, children}) => {
return (
<p className={`leading-7 [&:not(:first-child)]:mt-6 ${className}`}>
{children}
</p>
)
}
const Blockquote: React.FC<Props> = ({className, children}) => {
return (
<blockquote className={`mt-6 border-l-2 pl-6 italic ${className}`}>
{children}
</blockquote>
)
}
const InlineCode: React.FC<Props> = ({className, children}) => {
return (
<code className={`relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold ${className}`}>
{children}
</code>
)
}
const Lead: React.FC<Props> = ({className, children}) => {
return (
<p className={`text-xl text-muted-foreground ${className}`}>
{children}
</p>
)
}
const Large: React.FC<Props> = ({className, children}) => {
return <div className={`text-lg font-semibold ${className}`}>{children}</div>
}
const Muted: React.FC<Props> = ({className, children}) => {
return (
<p className={`text-sm text-muted-foreground ${className}`}>{children}.</p>
)
}
export { H1, H2, H3, H4, P, Lead, Large, Muted, Blockquote, InlineCode}
@thebrrt
Copy link

thebrrt commented Nov 18, 2024

thank you king 👑

@joshuafredrickson
Copy link

Very helpful, thank you!

@ruiyuwg
Copy link

ruiyuwg commented May 22, 2025

This is amazing! Thank You!!!!

@jdev-htetwaiyan
Copy link

This is very helpful. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment