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

AppBar API

원문 보기 위키 갱신

AppBar API (앱 바 API)

React AppBar 컴포넌트의 API 레퍼런스 문서예요. 이 모듈에서 내보내는 props, CSS, 그리고 기타 API에 대해 알아볼 수 있어요.

출처: App Bar API

본문

데모

이 React 컴포넌트의 사용 예시와 자세한 내용은 컴포넌트 데모 페이지를 방문해 주세요: App Bar

가져오기 (Import)

import AppBar from '@mui/material/AppBar';
// or
import { AppBar } from '@mui/material';

번들 크기 최소화 가이드를 읽고 두 방식의 차이에 대해 알아보세요.

Props

Paper 컴포넌트의 props도 사용할 수 있어요.

이름 타입 기본값 설명
children node - 컴포넌트의 내용이에요.
classes object - 컴포넌트에 적용된 스타일을 재정의하거나 확장해요. 자세한 내용은 아래의 CSS 클래스 API를 참고하세요.
color 'default'| 'inherit'| 'primary'| 'secondary'| 'transparent'| 'error'| 'info'| 'success'| 'warning'| string 'primary' 컴포넌트의 색상이에요. 기본 및 커스텀 테마 색상을 모두 지원하며, 팔레트 사용자 지정 가이드에 나와 있는 것처럼 추가할 수 있어요.
elevation number 4 그림자 깊이(shadow depth)로, 스펙에서 dp에 해당해요. 0에서 24 사이의 값을 허용해요 (포함).
enableColorOnDark bool false true라면 다크 모드에서 color prop이 적용돼요.
position 'absolute'| 'fixed'| 'relative'| 'static'| 'sticky' 'fixed' 포지셔닝 타입이에요. 각 옵션의 동작은 MDN 웹 문서에 설명되어 있어요. 참고: sticky는 보편적으로 지원되지 않으며, 사용할 수 없을 때 static으로 폴백돼요.
square bool true false라면 둥근 모서리가 활성화돼요.
sx Array<func| object| bool>| func| object - 시스템 오버라이드와 추가 CSS 스타일을 정의할 수 있게 해주는 시스템 prop이에요. 자세한 내용은 sx 페이지를 참고하세요.

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

상속 (Inheritance)

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

테마 기본 props (Theme default props)

MuiAppBar을 사용해 테마에서 이 컴포넌트의 기본 props를 변경할 수 있어요.

CSS 클래스

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

클래스 이름 규칙 이름 설명
.MuiAppBar-colorDefault colorDefault color="default"일 때 루트 요소에 적용되는 스타일이에요.
.MuiAppBar-colorError colorError color="error"일 때 루트 요소에 적용되는 스타일이에요.
.MuiAppBar-colorInfo colorInfo color="info"일 때 루트 요소에 적용되는 스타일이에요.
.MuiAppBar-colorInherit colorInherit color="inherit"일 때 루트 요소에 적용되는 스타일이에요.
.MuiAppBar-colorPrimary colorPrimary color="primary"일 때 루트 요소에 적용되는 스타일이에요.
.MuiAppBar-colorSecondary colorSecondary color="secondary"일 때 루트 요소에 적용되는 스타일이에요.
.MuiAppBar-colorSuccess colorSuccess color="success"일 때 루트 요소에 적용되는 스타일이에요.
.MuiAppBar-colorTransparent colorTransparent color="transparent"일 때 루트 요소에 적용되는 스타일이에요.
.MuiAppBar-colorWarning colorWarning color="warning"일 때 루트 요소에 적용되는 스타일이에요.
.MuiAppBar-positionAbsolute positionAbsolute position="absolute"일 때 루트 요소에 적용되는 스타일이에요.
.MuiAppBar-positionFixed positionFixed position="fixed"일 때 루트 요소에 적용되는 스타일이에요.
.MuiAppBar-positionRelative positionRelative position="relative"일 때 루트 요소에 적용되는 스타일이에요.
.MuiAppBar-positionStatic positionStatic position="static"일 때 루트 요소에 적용되는 스타일이에요.
.MuiAppBar-positionSticky positionSticky position="sticky"일 때 루트 요소에 적용되는 스타일이에요.
.MuiAppBar-root root 루트 요소에 적용되는 스타일이에요.

다음과 같은 사용자 지정 옵션 중 하나를 사용해 컴포넌트의 스타일을 재정의할 수 있어요:

  • 전역 클래스 이름(global class name)과 함께 사용하는 방법
  • 커스텀 테마에서 컴포넌트의 styleOverrides 속성의 일부로 규칙 이름(rule name)을 사용하는 방법

소스 코드 (Source code)

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

더 알아보기

더 자세한 내용은 MUI 공식 문서를 참고해 주세요.