Taster

진단부품톤 고르기
부품 갤러리 / Prose

Prose

Typography

Reading column with comfortable measure, paragraph rhythm, quotes without side bars and policy pages that render as plain prose.

내 사이트에서 가져오기

색을 고르면 아래 부품이 그 색으로 바뀝니다.

실제로 돌아가는 부품입니다. 눌러 보고 입력해 보세요.

내 앱에 넣기

  1. 아직 npm 패키지가 없어서 Taster 리포를 받아 그 안의 명령을 씁니다. 내 앱 폴더가 들어 있는 폴더에서 한 번만 받습니다.

    git clone https://github.com/makim-414/taster.git && npm ci --prefix taster/packages/engine
  2. 내 앱 폴더에서 이 부품을 넣습니다. 부품 파일과 토큰 파일이 src/components/taster 에 들어갑니다.

    node ../taster/packages/engine/cli.mjs add content/prose --from https://taster-six.vercel.app --dir src/components/taster
  3. 부품은 Tailwind 클래스로 그리고, Taster 프리셋이 그 클래스를 토큰에 연결합니다. Tailwind CSS 를 설치하고, tokens.css 를 앱 루트에서 한 번 불러온 뒤, 앱 루트에 이 설정을 둡니다. 프리셋이 없으면 빌드는 되어도 부품이 스타일 없이 나옵니다.

    // tailwind.config.cjs
    module.exports = {
      presets: [require('./src/components/taster/tailwind-preset.cjs')],
      content: ['./index.html', './src/**/*.{ts,tsx}'],
    };

    Tailwind v3 는 이 파일을 그대로 읽습니다. v4 는 Tailwind 를 불러오는 src/ 의 스타일시트 맨 위에 이 두 줄을 넣습니다.

    @import "tailwindcss";
    @config "../tailwind.config.cjs";

    tokens.css 는 :root 에 --bg, --text, --border, --accent 를 정의합니다. 내 앱의 스타일시트가 같은 이름을 뒤에서 다시 정의하면 그쪽 색이 이깁니다. 새 Vite 앱의 스타터 CSS 처럼 그런 변수가 있으면 지우거나 이름을 바꾸세요.

언제 쓰나요

  • Long-form proseReading column with comfortable measure, paragraph rhythm, quotes without side bars and policy pages that render as plain prose.
  • Korean line breaking and alignmentSet word-break: keep-all with overflow-wrap: anywhere for long strings, and left-align Korean text instead of justifying it.
  • Korean type setupDeclare lang on the document, name a Korean face such as Pretendard on purpose, body at 15 to 16px with line height 1.6 to 1.8, no uppercase on Hangul, tracking between 0 and minus 0.02em, and weight or color instead of synthetic italics.

대신 없애 주는 AI 티

  • Tight line height on Korean text (KO-03)
  • Korean body text that is too small (KO-11)
  • Long content as one image (LAY-07)
  • Korean words broken mid-word (KO-01)
  • Justified Korean paragraphs (KO-10)
  • A single syllable alone on a Korean heading's last line (KO-13)
  • Only a Latin font declared for Korean text (KO-02)
  • Uppercase transform on Korean text (KO-04)
  • Letter spacing that is too wide or too tight on Korean (KO-05)
  • Fake italic on Korean (KO-06)
  • Missing or wrong lang attribute on a Korean page (KO-08)
  • Tight line height on a large Korean heading (KO-12)

정보

설치할 패키지
tailwindcss
라이선스
MIT
코드 보기
import * as React from 'react'
import { cn } from '../blocks/_cn'
import { useStyleOnce } from '../motion/_motion'

// Prose: a reading column that sets plain HTML (Markdown output, CMS rich text) with a comfortable measure,
// a long-form line height, headings with more space above than below, quiet quotes, lists, inline code,
// code blocks, tables and figures. Wrap any rendered HTML in it; no class names are needed inside.
// Follows patterns/long-form-prose and patterns/korean-type-setup: 65ch for Latin, about 36 full-width
// characters for Korean (lang="ko"), line height 1.7 and 1.8 for Korean, never justified, words kept whole,
// blockquotes indented instead of given a colored side bar (AC-10). Everything reads tokens, so the
// density axis (--lh-normal) and the type scale reshape it.
// Original code, MIT.

const CSS = `
.dsg-prose{max-width:65ch;color:var(--text);font-size:var(--t-title);line-height:calc(var(--lh-normal) + 0.2);word-break:keep-all;overflow-wrap:break-word;text-align:start}
.dsg-prose:lang(ko){max-width:36em;line-height:calc(var(--lh-normal) + 0.3)}
.dsg-prose>*+*{margin-top:1.15em}
.dsg-prose h2{font-size:var(--t-h2);font-weight:var(--w-semi);line-height:var(--lh-snug);margin-top:2em;margin-bottom:0;text-wrap:balance}
.dsg-prose h3{font-size:calc(var(--t-title) + 2px);font-weight:var(--w-semi);line-height:var(--lh-snug);margin-top:1.75em;text-wrap:balance}
.dsg-prose h2+*,.dsg-prose h3+*{margin-top:0.6em}
.dsg-prose p,.dsg-prose li{text-wrap:pretty}
.dsg-prose a{color:var(--text);text-decoration:underline;text-underline-offset:0.2em;text-decoration-thickness:1px;border-radius:var(--r-sm)}
.dsg-prose a:hover{color:var(--text-muted)}
.dsg-prose a:focus-visible{outline:2px solid var(--ring);outline-offset:2px}
.dsg-prose strong{font-weight:var(--w-semi)}
.dsg-prose ul,.dsg-prose ol{padding-left:1.4em}
.dsg-prose ul{list-style:disc}
.dsg-prose ol{list-style:decimal}
.dsg-prose li+li{margin-top:0.5em}
.dsg-prose li::marker{color:var(--text-subtle)}
.dsg-prose blockquote{margin-left:0;padding-left:1.5em;color:var(--text-muted)}
.dsg-prose hr{border:0;border-top:1px solid var(--border);margin:2.5em 0}
.dsg-prose code{font-size:0.9em;background:var(--bg-sunken);border-radius:var(--r-sm);padding:0.1em 0.35em}
.dsg-prose pre{font-size:var(--t-sm);line-height:var(--lh-normal);background:var(--bg-sunken);border-radius:var(--r-md);padding:var(--sp-4);overflow-x:auto;word-break:normal}
.dsg-prose pre code{background:none;padding:0;font-size:inherit}
.dsg-prose figure{margin:2em 0}
.dsg-prose img{display:block;max-width:100%;height:auto;border-radius:var(--r-md)}
.dsg-prose figcaption{margin-top:var(--sp-2);font-size:var(--t-sm);color:var(--text-subtle)}
.dsg-prose table{width:100%;border-collapse:collapse;font-size:var(--t-body);font-variant-numeric:tabular-nums}
.dsg-prose th{text-align:left;font-weight:var(--w-med);color:var(--text-muted);border-bottom:1px solid var(--border);padding:var(--sp-2) var(--sp-3) var(--sp-2) 0}
.dsg-prose td{border-bottom:1px solid var(--border-soft);padding:var(--sp-2) var(--sp-3) var(--sp-2) 0;vertical-align:top}
`

export interface ProseProps extends React.HTMLAttributes<HTMLDivElement> {
  /**
   * Rendered HTML as a string, for Markdown or CMS output. It is set as markup with no cleaning, so pass only HTML you
   * trust. Anything a user or another site wrote goes through a sanitizer such as DOMPurify first, or markup in it
   * (an onerror handler, say) runs script on your page. For text you do not trust and do not need as HTML, pass it as children instead.
   * @example
   * import DOMPurify from 'dompurify'
   * <Prose html={DOMPurify.sanitize(markdownToHtml(post.body))} />
   */
  html?: string
}

export const Prose = React.forwardRef<HTMLDivElement, ProseProps>(function Prose({ html, className, children, ...props }, ref) {
  useStyleOnce('dsg-prose-css', CSS)
  if (html !== undefined) {
    return <div ref={ref} className={cn('dsg-prose', className)} dangerouslySetInnerHTML={{ __html: html }} {...props} />
  }
  return (
    <div ref={ref} className={cn('dsg-prose', className)} {...props}>
      {children}
    </div>
  )
})