본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

Typography (타이포그래피)

원문 보기 위키 갱신

Typography는 React Aria Components의 Text를 기반으로 만든, 제목·본문·인라인 코드를 위한 의미론적 타이포그래피 프리미티브예요. 텍스트의 스타일과 의미 구조를 함께 관리하고 싶을 때 사용해요.

출처: HeroUI Typography

본문

사용법 (Usage)

import {Typography} from "@heroui/react";
{"name": "typography-default"}

구조 (Anatomy)

Typography는 기본적으로 시각적 type 값을 의미론적 요소에 매핑해요.

import {Typography} from "@heroui/react";

export default () => (
  <Typography type="h1">Heading</Typography>
);

예시 (Examples)

스케일 (Scale)

{"name": "typography-typography-scale"}

프리미티브 (Primitives)

{"name": "typography-primitives"}
  • Typography.Heading은 level={1..6}을 type="h1"부터 type="h6"까지 매핑해요.
  • Typography.Paragraph은 size="base" | "sm" | "xs"를 본문 텍스트 스타일에 매핑해요.
  • Typography.Code은 인라인 코드 스타일에 매핑해요.
  • Typography.Prose은 일반 HTML children으로 전달된 풍부한 콘텐츠를 스타일링해요.

프로즈 (Prose)

{"name": "typography-prose"}

Render Props

{"name": "typography-render-props"}

렌더링할 요소를 커스터마이징하려면 React Aria Components 스타일의 render 프롭을 사용할 수 있어요.

커스터마이징 (Customization)

Tailwind CSS

{"name": "typography-custom-styles"}

Global CSS

Typography 컴포넌트 클래스를 커스터마이징하려면 @layer components 지시어를 사용할 수 있어요. 더 알아보기.

@layer components {
  .typography--h1 {
    @apply font-extrabold tracking-tight;
  }

  .typography--code {
    @apply rounded-md bg-default-100 font-mono dark:bg-default-50/20;
  }
}

스타일링 참고 (Styling Reference)

HeroUI는 BEM 방법론을 따라 컴포넌트 변형과 상태를 재사용하고 쉽게 커스터마이징할 수 있게 해요.

CSS 클래스 (CSS Classes)

Typography 컴포넌트는 다음 CSS 클래스를 사용해요 (소스 스타일 보기):

기본 클래스 (Base Classes) [!toc]

  • .typography - 기본 타이포그래피 프리미티브
  • .typography-prose - 풍부한 프로즈 컨테이너

타입 클래스 (Type Classes) [!toc]

  • .typography--h1부터 .typography--h6
  • .typography--body, .typography--body-sm, .typography--body-xs
  • .typography--code

수식어 클래스 (Modifier Classes) [!toc]

  • .typography--align-start, .typography--align-center, .typography--align-end, .typography--align-justify
  • .typography--color-default, .typography--color-muted
  • .typography--truncate
  • .typography--weight-normal, .typography--weight-medium, .typography--weight-semibold, .typography--weight-bold

API 참고 (API Reference)

Typography

Prop Type Default Description
type 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'body' | 'body-sm' | 'body-xs' | 'code' 'body' Semantic typography style.
align 'start' | 'center' | 'end' | 'justify' 'start' Text alignment.
color 'default' | 'muted' 'default' Text color.
weight 'normal' | 'medium' | 'semibold' | 'bold' - Font weight override.
truncate boolean - Truncates the text to one line with ellipsis.
render DOMRenderFunction - Custom render function from React Aria.
children ReactNode - Text content.

더 알아보기 (Learn more)