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

IconButton

원문 보기 위키 갱신

IconButton은 텍스트 라벨 대신 아이콘을 표시하는 버튼에 사용되는 컴포넌트입니다. 버튼의 목적이 텍스트 라벨 대신 아이콘으로 쉽게 이해될 때 사용합니다.

출처: 문서

본문

IconButton은 텍스트 라벨 대신 아이콘을 보여 주는 버튼에 사용합니다. 아이콘만으로 버튼의 목적을 쉽게 이해할 수 있을 때 사용하세요.

React 예제 (React examples)

기본 (Default)

<IconButton icon={HeartIcon} aria-label="Favorite" />

스타일 변형 (Style variants)

IconButton 컴포넌트는 계층이나 의도를 시각적으로 강화하는 다양한 변형(variant)을 제공합니다. 여기서는 'primary' 변형만 보여 줍니다.

<IconButton icon={HeartIcon} variant="primary" aria-label="Favorite" />

크기 변형 (Size variants)

IconButton은 다양한 크기로 렌더링할 수 있습니다. 이 예제는 'small' 크기 변형을 보여 줍니다.

<IconButton icon={HeartIcon} size="small" aria-label="Favorite" />

키보드 단축키로 활성화 가능 (May be activated by a keyboard shortcut)

<IconButton
  icon={InboxIcon}
  aria-label="Notifications"
  description="You have unread notifications"
  keybindingHint="G+N"
/>

로딩 (Loading)

<IconButton icon={HeartIcon} loading aria-label="Favorite" />

비활성 (Inactive)

비활성(Inactive) 상태의 버튼은 시각적으로 비활성화된 것처럼 보이지만, 활성 버튼과 동일한 상호작용을 모두 받아들입니다.

<IconButton icon={HeartIcon} inactive aria-label="Favorite" />

더 많은 코드 예제 (More code examples)

앞선 예제들은 IconButton 컴포넌트의 전체 기능 중 선별된 일부입니다. 더 많은 예제는 IconButton Storybook 스토리를 참고하세요.

Props

IconButton

Name Default Description
children Required React.ReactNode — Button 설명이 됩니다.
as 'button' React.ElementType
href string — as가 'a'로 설정된 경우에만 사용할 수 있습니다. 버튼이 링크하는 URL입니다. as가 'a'이면 이 prop은 필수입니다.
variant 'default' | 'primary' | 'danger' | 'invisible' | 'link' — 버튼의 모양과 느낌을 변경합니다(변형마다 다릅니다).
size 'small' | 'medium' | 'large' — 아이콘 버튼 컴포넌트의 크기를 변경합니다.
inactive boolean — 버튼이 시각적으로 비활성화된 것처럼 보이지만, 활성 버튼과 동일한 상호작용을 모두 받아들일지 여부
icon Component — octicon을 제공하세요. 버튼 중앙에 배치됩니다.
aria-label string — aria label로 버튼의 기능을 설명하세요. 좋은 대체 텍스트 작성 팁은 alt text 지침을 참고하세요.
keyshortcuts Deprecated string — keybindingHint를 대신 사용하세요.
keybindingHint string | string[] — 이 버튼의 툴팁에 표시할 선택적 키보드 단축키 힌트. 단일 단축키는 문자열을, 여러 단축키("or"로 연결됨)를 보여 주려면 문자열 배열을 전달하세요. 올바른 형식은 KeybindingHint 컴포넌트 문서를 참고하세요. 툴팁이 재정의되거나 비활성화되면 효과가 없습니다. 이 버튼의 키 바인딩은 바인딩하지 않습니다 — 시각적 힌트일 뿐입니다.
tooltipDirection 's' 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'nw' — 툴팁의 방향.
description string — description이 제공되면 Tooltip으로 버튼을 설명합니다. 그다음 aria-label이 버튼을 라벨링합니다.
  • Button 사용법, Button, Tooltip

더 알아보기 (Learn more)