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

IconButton API

원문 보기 위키 갱신

IconButton API (아이콘 버튼 API)

IconButton은 아이콘을 표시하는 버튼 컴포넌트예요. 이 페이지에서는 이 컴포넌트의 props, CSS 클래스, 그리고 기타 API를 하나씩 설명해 드릴게요.

출처: 문서

본문

데모 (Demos)

이 React 컴포넌트의 사용법과 세부 사항은 컴포넌트 데모 페이지에서 확인할 수 있어요.

  • Button
  • Number Field

Import

import IconButton from '@mui/material/IconButton';
// 또는
import { IconButton } from '@mui/material';

번들 크기를 줄이는 방법이 궁금하시다면, 이 차이에 대한 가이드 문서를 읽어 보시면 좋아요.

사용 가능한 아이콘 옵션에 대해서는 문서의 Icons 섹션을 참고하세요.

Props

ButtonBase 컴포넌트의 props도 그대로 사용할 수 있어요.

Name Type Default Description
children node - The icon to display.
classes object - Override or extend the styles applied to the component. See CSS classes API below for more details.
color 'inherit'| 'default'| 'primary'| 'secondary'| 'error'| 'info'| 'success'| 'warning'| string 'default' The color of the component. It supports both default and custom theme colors, which can be added as shown in the palette customization guide.
disabled bool false If true, the component is disabled.
disableFocusRipple bool false If true, the keyboard focus ripple is disabled.
disableRipple bool false If true, the ripple effect is disabled. ⚠️ Without a ripple there is no styling for :focus-visible by default. Be sure to highlight the element by applying separate styles with the .Mui-focusVisible class.
edge 'end'| 'start'| false false If given, uses a negative margin to counteract the padding on one side (this is often helpful for aligning the left or right side of the icon with content above or below, without ruining the border size and shape).
loading bool null If true, the loading indicator is visible and the button is disabled. If true | false, the loading wrapper is always rendered before the children to prevent Google Translation Crash.
loadingIndicator node <CircularProgress color="inherit" size={16} /> Element placed before the children if the button is in loading state. The node should contain an element with role="progressbar" with an accessible name. By default, it renders a CircularProgress that is labeled by the button itself.
size 'small'| 'medium'| 'large'| string 'medium' The size of the component. small is equivalent to the dense button styling.
sx Array<func| object| bool>| func| object - The system prop that allows defining system overrides as well as additional CSS styles. See the sx page for more details.

ref는 루트 요소로 전달돼요.

상속 (Inheritance)

위에서 명시적으로 다루지는 않았지만, ButtonBase 컴포넌트의 props도 IconButton에서 사용할 수 있어요. 이를 활용해 중첩된 컴포넌트를 대상으로 지정할 수 있어요.

테마 기본 props (Theme default props)

MuiIconButton을 사용하면 테마를 통해 이 컴포넌트의 기본 props를 바꿀 수 있어요.

CSS 클래스 (CSS classes)

이 클래스들은 CSS로 스타일을 지정할 때 유용해요. 특정 상태가 트리거되면 컴포넌트의 슬롯에 적용돼요.

Class name Rule name Description
.Mui-disabled State class applied to the root element if disabled={true}.
.MuiIconButton-colorError colorError Styles applied to the root element if color="error".
.MuiIconButton-colorInfo colorInfo Styles applied to the root element if color="info".
.MuiIconButton-colorInherit colorInherit Styles applied to the root element if color="inherit".
.MuiIconButton-colorPrimary colorPrimary Styles applied to the root element if color="primary".
.MuiIconButton-colorSecondary colorSecondary Styles applied to the root element if color="secondary".
.MuiIconButton-colorSuccess colorSuccess Styles applied to the root element if color="success".
.MuiIconButton-colorWarning colorWarning Styles applied to the root element if color="warning".
.MuiIconButton-edgeEnd edgeEnd Styles applied to the root element if edge="end".
.MuiIconButton-edgeStart edgeStart Styles applied to the root element if edge="start".
.MuiIconButton-loading loading Styles applied to the root element if loading={true}.
.MuiIconButton-loadingIndicator loadingIndicator Styles applied to the loadingIndicator element.
.MuiIconButton-loadingWrapper loadingWrapper Styles applied to the loadingWrapper element.
.MuiIconButton-root root Styles applied to the root element.
.MuiIconButton-sizeLarge sizeLarge Styles applied to the root element if size="large".
.MuiIconButton-sizeMedium sizeMedium Styles applied to the root element if size="medium".
.MuiIconButton-sizeSmall sizeSmall Styles applied to the root element if size="small".

컴포넌트의 스타일을 다음 방법 중 하나로 재정의할 수 있어요.

  • 전역 클래스 이름으로 재정의하기
  • 커스텀 테마의 컴포넌트 styleOverrides 속성에 규칙 이름(rule name)으로 재정의하기

소스 코드 (Source code)

이 페이지에서 원하는 정보를 찾지 못했다면, 컴포넌트의 구현 코드를 살펴보시면 더 자세한 내용을 확인할 수 있어요.

더 알아보기