CloseButton (닫기 버튼)
CloseButton은 대화상자(dialog), 모달(modal), 콘텐츠를 닫을 때 사용하는 버튼 컴포넌트예요. 기본 스타일의 닫기 아이콘 버튼을 렌더링하며, iconProps로 아이콘의 색상과 크기를 쉽게 조절할 수 있어요. 자식 요소를 넣으면 기본 닫기 아이콘 대신 원하는 콘텐츠로 바꿀 수도 있답니다.
출처: 문서
본문
Import
import { CloseButton } from 'heroui-native';
Usage
Basic Usage
CloseButton 컴포넌트는 기본 스타일로 닫기 아이콘 버튼을 렌더링해요.
<CloseButton />
Custom Icon Color
iconProps prop으로 아이콘 색상을 커스텀해요.
<CloseButton iconProps={{ color: themeColorDanger }} />
<CloseButton iconProps={{ color: themeColorAccent }} />
Custom Icon Size
iconProps prop으로 아이콘 크기를 조절해요.
<CloseButton iconProps={{ size: 24 }} />
Custom Children
기본 닫기 아이콘을 원하는 콘텐츠로 바꿔요.
<CloseButton>
<CustomIcon />
</CloseButton>
Disabled State
버튼을 비활성화해서 상호작용을 막아요.
<CloseButton isDisabled />
Example
import { CloseButton, useThemeColor } from 'heroui-native';
import { Ionicons } from '@expo/vector-icons';
import { View } from 'react-native';
import { withUniwind } from 'uniwind';
const StyledIonicons = withUniwind(Ionicons);
export default function CloseButtonExample() {
const themeColorForeground = useThemeColor('foreground');
const themeColorDanger = useThemeColor('danger');
return (
<View className="flex-1 px-5 items-center justify-center">
<View className="flex-row items-center gap-4">
<CloseButton />
<CloseButton iconProps={{ color: themeColorDanger }} />
<CloseButton>
<StyledIonicons
name="close-circle"
size={28}
color={themeColorForeground}
/>
</CloseButton>
<CloseButton isDisabled />
</View>
</View>
);
}
더 많은 예시는 GitHub repository에서 찾을 수 있어요.
API Reference
CloseButton
CloseButton은 Button 컴포넌트의 모든 props를 상속받아요. 기본값은 variant='tertiary', size='sm', isIconOnly=true예요.
| prop | type | default | 설명 |
|---|---|---|---|
iconProps |
CloseButtonIconProps |
- | 닫기 아이콘을 커스텀하기 위한 Props |
children |
React.ReactNode |
- | 기본 닫기 아이콘을 대체할 커스텀 콘텐츠 |
isDisabled, className, animation, feedbackVariant 및 모든 Pressable props를 포함한 상속된 props는 Button API Reference를 참고해요.
CloseButtonIconProps
| prop | type | default | 설명 |
|---|---|---|---|
size |
number |
18 |
아이콘의 크기 |
color |
string |
테마의 muted 색상 사용 | 아이콘의 색상 |