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

Description (설명)

원문 보기 위키 갱신

폼 필드나 다른 컴포넌트에 보조 설명 텍스트를 제공하는 컴포넌트예요. 입력에 대한 힌트나 부가 정보를 보여줄 때 사용해요.

출처: HeroUI Description

본문

사용법 (Usage)

import { Description } from '@heroui/react';
{"demo": "description-basic"}

예제 (Examples)

폼 필드와 함께 (With Form Fields)

<div className="flex flex-col gap-1">
  <Label htmlFor="password">Password</Label>
  <Input id="password" type="password" aria-describedby="password-description" />
  <Description id="password-description">
    Must be at least 8 characters with one uppercase letter
  </Description>
</div>

TextField와 통합하기 (Integration with TextField)

import {TextField, Label, Input, Description} from '@heroui/react';

<TextField type="email">
  <Label>Email</Label>
  <Input placeholder="Enter your email" />
  <Description>We'll never share your email</Description>
</TextField>

TextField 컴포넌트를 사용하면 레이블과 설명에 대한 접근성 속성이 자동으로 적용돼요.

커스터마이징 (Customization)

Tailwind CSS

{"demo": "description-custom-styles"}

Global CSS

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

@layer components {
  .description {
    @apply text-muted;
  }
}

스타일링 참조 (Styling Reference)

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

CSS 클래스 (CSS Classes)

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

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

  • .description - muted 텍스트 색상이 적용된 기본 설명 스타일

API 참조 (API Reference)

Description

Prop Type Default Description
className string - Additional CSS classes
children ReactNode - The content of the description

접근성 (Accessibility)

Description 컴포넌트는 다음과 같은 방식으로 접근성을 높여요:

  • 스크린 리더가 인식할 수 있는 의미론적 HTML 사용
  • React Aria 통합을 위한 slot="description" 속성 제공
  • 적절한 텍스트 대비 비율 지원

더 알아보기 (Learn more)