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

닫기 버튼 (CloseButton)

원문 보기 위키 갱신

CloseButton은 다이얼로그나 모달 창을 닫거나 콘텐츠를 해제할 때 사용하는 버튼 컴포넌트예요.

출처: HeroUI CloseButton

본문

사용 방법 (Usage)

import { CloseButton } from "@heroui/react";
{
  "preview": "close-button-default"
}

예제 (Examples)

인터랙티브 (Interactive)

{
  "preview": "close-button-interactive"
}

사용자 지정 아이콘 (With Custom Icon)

{
  "preview": "close-button-with-custom-icon"
}

커스터마이징 (Customization)

Tailwind CSS

{
  "preview": "close-button-custom-styles"
}

글로벌 CSS (Global CSS)

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

@layer components {
  .close-button {
    @apply bg-red-100 text-red-800 hover:bg-red-200;
  }

  .close-button--custom {
    @apply rounded-full border-2 border-red-300;
  }
}

스타일 참조 (Styling Reference)

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

CSS 클래스 (CSS Classes)

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

기본 클래스 (Base Classes)

  • .close-button - 컴포넌트의 기본 스타일

변형 클래스 (Variant Classes)

  • .close-button--default - 기본 변형

인터랙티브 상태 (Interactive States)

이 컴포넌트는 유연성을 위해 CSS 의사 클래스와 데이터 속성을 모두 지원해요:

  • 호버 (Hover): :hover 또는 [data-hovered="true"]
  • 활성/눌림 (Active/Pressed): :active 또는 [data-pressed="true"]
  • 포커스 (Focus): :focus-visible 또는 [data-focus-visible="true"]
  • 비활성 (Disabled): :disabled 또는 [aria-disabled="true"]

API 참조 (API Reference)

CloseButton

Prop Type Default Description
variant "default" "default" Visual variant of the button
children ReactNode | function <CloseIcon /> Content to display (defaults to close icon)
onPress () => void - Handler called when the button is pressed
isDisabled boolean false Whether the button is disabled

React Aria Button Props

CloseButton은 React Aria Button의 모든 props를 상속해요. 일반적인 props는 다음과 같아요:

Prop Type Description
aria-label string Accessible label for screen readers
aria-labelledby string ID of element that labels the button
aria-describedby string ID of element that describes the button

렌더 props (Render Props)

렌더 prop 패턴을 사용할 때 다음 값이 제공돼요:

Prop Type Description
isHovered boolean Whether the button is hovered
isPressed boolean Whether the button is pressed
isFocused boolean Whether the button is focused
isDisabled boolean Whether the button is disabled

더 알아보기 (Learn more)

HeroUI CloseButton에 대해 더 알아보려면 공식 문서를 확인해 주세요.