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

Disclosure

원문 보기 위키 갱신

헤더(제목과 트리거 버튼 포함)와 콘텐츠를 감싸는 패널로 구성된 접고 펼치는 접이식 섹션 컴포넌트입니다.

출처: HeroUI page-name

본문

사용법 (Usage)

import { Disclosure } from '@heroui/react';
"disclosure-basic"

구조 (Anatomy)

import { Disclosure } from '@heroui/react';

export default () => (
  <Disclosure>
    <Disclosure.Heading>
      <Disclosure.Trigger>
        <Disclosure.Indicator />
      </Disclosure.Trigger>
    </Disclosure.Heading>
    <Disclosure.Content/>
  </Disclosure>
)

예제 (Examples)

렌더 함수 (Render Function)

"disclosure-render-function"

커스터마이징 (Customization)

Tailwind CSS

"disclosure-custom-styles"

Global CSS

Disclosure 컴포넌트 클래스를 커스터마이징하려면 @layer components 지시어를 사용하면 됩니다. 자세히 알아보기.

@layer components {
  .disclosure {
    @apply relative;
  }

  .disclosure__trigger {
    @apply cursor-pointer;
  }

  .disclosure__indicator {
    @apply transition-transform duration-300;
  }

  .disclosure__content {
    @apply overflow-hidden transition-all;
  }
}

스타일링 참조 (Styling Reference)

HeroUI는 BEM 방법론을 따르므로 컴포넌트 변형과 상태를 재사용하고 커스터마이징하기 쉽습니다.

CSS 클래스

Disclosure 컴포넌트는 다음 CSS 클래스를 사용합니다 (소스 스타일 보기):

기본 클래스 [!toc]

  • .disclosure - 기본 컨테이너 스타일
  • .disclosure__heading - 헤딩 래퍼
  • .disclosure__trigger - 트리거 버튼 스타일
  • .disclosure__indicator - 셰브론(chevron) 표시기 스타일
  • .disclosure__content - 애니메이션이 포함된 콘텐츠 컨테이너

상호작용 상태 (Interactive States)

컴포넌트는 유연성을 위해 CSS 의사 클래스(pseudo-classes)와 데이터 속성(data attributes)을 모두 지원합니다:

  • 펼침 (Expanded): 회전을 위한 표시기의 [data-expanded="true"]
  • 포커스 (Focus): 트리거의 :focus-visible 또는 [data-focus-visible="true"]
  • 비활성 (Disabled): 트리거의 :disabled 또는 [aria-disabled="true"]
  • 숨김 (Hidden): 가시성을 위한 콘텐츠의 [aria-hidden="false"]

API 참조 (API Reference)

Disclosure

Prop Type Default Description
isExpanded boolean false 펼침 상태를 제어합니다
onExpandedChange (isExpanded: boolean) => void - 펼침 상태가 변경될 때의 콜백
isDisabled boolean false disclosure가 비활성화되었는지 여부
children ReactNode | RenderFunction - 렌더링할 콘텐츠
className string - 추가 CSS 클래스
render DOMRenderFunction<keyof React.JSX.IntrinsicElements, DisclosureRenderProps> - 기본 DOM 요소를 커스텀 렌더 함수로 재정의합니다.

DisclosureTrigger

Prop Type Default Description
children ReactNode | RenderFunction - 트리거 콘텐츠
className string - 추가 CSS 클래스

DisclosureContent

Prop Type Default Description
children ReactNode - 표시/숨김할 콘텐츠
className string - 추가 CSS 클래스
render DOMRenderFunction<keyof React.JSX.IntrinsicElements, DisclosureContentRenderProps> - 기본 DOM 요소를 커스텀 렌더 함수로 재정의합니다.

렌더 Props (Render Props)

렌더 prop 패턴을 사용할 때 다음 값들이 제공됩니다:

Prop Type Description
isExpanded boolean 현재 펼침 상태
isDisabled boolean disclosure가 비활성화되었는지 여부

더 알아보기 (Learn more)