Typography
scificn/typographyFreeComponent
Type scale components for headings, body text, and code display.
Live preview
live · rendered by the registry
Rendered by scificn on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://www.scificn.dev/r/typography.jsonSource
1import * as React from 'react'2import { cva, type VariantProps } from 'class-variance-authority'3import { cn } from '@/lib/utils'45const typographyVariants = cva('font-mono', {6 variants: {7 variant: {8 H1: 'text-3xl font-bold uppercase tracking-[0.15em] text-[var(--color-green)] text-shadow-[var(--text-glow-green)]',9 H2: 'text-2xl font-semibold uppercase tracking-[0.12em] text-[var(--color-green)]',10 H3: 'text-xl font-semibold uppercase tracking-[0.1em] text-[var(--text-secondary)]',11 H4: 'text-base font-medium uppercase tracking-widest text-[var(--text-secondary)]',12 P: 'text-sm leading-relaxed text-[var(--text-secondary)]',13 LEAD: 'text-base leading-relaxed text-[var(--text-secondary)] opacity-90',14 MUTED: 'text-xs text-[var(--text-muted)]',15 CODE: 'text-sm bg-[var(--surface-raised)] border border-[var(--border)] px-1.5 py-0.5 text-[var(--color-green)] inline-block',16 },17 },18 defaultVariants: { variant: 'P' },19})2021type VariantElement = {22 H1: 'h1'23 H2: 'h2'24 H3: 'h3'25 H4: 'h4'26 P: 'p'27 LEAD: 'p'28 MUTED: 'p'29 CODE: 'code'30}3132const variantTag: VariantElement = {33 H1: 'h1',34 H2: 'h2',35 H3: 'h3',36 H4: 'h4',37 P: 'p',38 LEAD: 'p',39 MUTED: 'p',40 CODE: 'code',41}4243export interface TypographyProps44 extends React.HTMLAttributes<HTMLElement>,45 VariantProps<typeof typographyVariants> {46 as?: keyof React.JSX.IntrinsicElements47}4849const Typography = React.forwardRef<HTMLElement, TypographyProps>(50 ({ className, variant = 'P', as, children, ...props }, ref) => {51 const Tag = (as ?? variantTag[variant as keyof VariantElement] ?? 'p') as React.ElementType52 return (53 <Tag54 ref={ref}55 className={cn(typographyVariants({ variant }), className)}56 {...props}57 >58 {children}59 </Tag>60 )61 }62)63Typography.displayName = 'Typography'6465export { Typography, typographyVariants }
What it pulls in
npm packages
More from scificn
All 33 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Alertalert | scificn | Components | Free | 1 dep | |
| Badgebadge | scificn | Components | Free | 1 dep | |
| Bar Chartbar-chart | scificn | Components | Free | no deps | |
| Breadcrumbbreadcrumb | scificn | Components | Free | no deps | |
| Buttonbutton | scificn | Components | Free | 2 deps | |
| Cardcard | scificn | Components | Free | no deps | |
| Checkboxcheckbox | scificn | Components | Free | 1 dep | |
| Dialogdialog | scificn | Components | Free | 1 dep |
