배너
배너 (Banner)
QBanner 컴포넌트는 눈에 띄는 메시지와 관련된 선택적 액션을 표시하기 위한 배너 요소를 만들어요.
출처: 문서
본문
QBanner 컴포넌트는 눈에 띄는 메시지와 관련된 선택적 액션을 표시하기 위한 배너 요소를 만들어요.
Material Design 스펙에 따르면 배너는 "화면 상단, 상단 앱 바(top app bar) 아래에 표시"되어야 해요 — 하지만 물론 의미 있는 곳 어디든, 심지어 QDialog 안에도 넣을 수 있어요.
QBanner API
Props
inline-actions(boolean, optional) 액션을 콘텐츠와 같은 줄에 표시dense(boolean, optional) Dense 모드; 공간을 덜 차지함rounded(boolean, optional) 컴포넌트의 정사각형 모양에 작은 표준 border-radius 적용dark(boolean, optional), defaultnull배경이 어두운 색임을 컴포넌트에 알림
Slots
#default배너 콘텐츠가 들어가는 곳#avatar아바타를 표시하는 슬롯 (제안: QIcon, QAvatar)#action배너 액션용 슬롯 (제안: QBtn)
Usage
"Basic" 예시:
<template>
<div class="q-gutter-sm">
<q-banner class="bg-primary text-white">
Unfortunately, the credit card did not go through, please try again.
<template #action>
<q-btn flat color="white" label="Dismiss" />
<q-btn flat color="white" label="Update Credit Card" />
</template>
</q-banner>
<q-banner :class="$q.dark.isActive ? 'bg-grey-9' : 'bg-grey-3'">
<template #avatar>
<q-icon name="signal_wifi_off" color="primary" />
</template>
You have lost connection to the internet. This app is offline.
<template #action>
<q-btn flat color="primary" label="Turn on Wifi" />
</template>
</q-banner>
<q-banner inline-actions class="text-white bg-red">
You have lost connection to the internet. This app is offline.
<template #action>
<q-btn flat color="white" label="Turn ON Wifi" />
</template>
</q-banner>
</div>
</template>
"Rounded border" 예시:
<template>
<div class="q-gutter-sm">
<q-banner rounded class="bg-purple-8 text-white">
We can't find your saved recipes until you sign in.
<template #action>
<q-btn flat color="white" label="Continue as a Guest" />
<q-btn flat color="white" label="Sign in" />
</template>
</q-banner>
</div>
</template>
"With an image" 예시:
<template>
<div class="q-gutter-sm">
<q-banner rounded :class="$q.dark.isActive ? 'bg-grey-9' : 'bg-grey-2'">
<template #avatar>
<img
alt="Mountains"
src="https://cdn.quasar.dev/img/mountains.jpg"
style="width: 100px; height: 64px"
/>
</template>
Could not retrieve travel data.
<template #action>
<q-btn flat label="Retry" />
</template>
</q-banner>
</div>
</template>
"Inline actions" 예시:
<template>
<div class="q-gutter-sm">
<q-banner inline-actions rounded class="bg-orange text-white">
You have lost connection to the internet. This app is offline.
<template #action>
<q-btn flat label="Turn ON Wifi" />
<q-btn flat label="Dismiss" />
</template>
</q-banner>
</div>
</template>
"Dense" 예시:
<template>
<div class="q-gutter-sm">
<q-banner dense class="bg-primary text-white">
Unfortunately, the credit card did not go through, please try again.
<template #action>
<q-btn flat color="white" label="Dismiss" />
<q-btn flat color="white" label="Update Credit Card" />
</template>
</q-banner>
<q-banner dense :class="$q.dark.isActive ? 'bg-grey-9' : 'bg-grey-2'">
<template #avatar>
<q-icon name="signal_wifi_off" color="primary" />
</template>
You have lost connection to the internet. This app is offline.
<template #action>
<q-btn flat color="primary" label="Turn on Wifi" />
</template>
</q-banner>
<q-banner dense inline-actions class="text-white bg-red">
You have lost connection to the internet. This app is offline.
<template #action>
<q-btn flat color="white" label="Turn ON Wifi" />
</template>
</q-banner>
</div>
</template>
Accessibility (v2.25+)
QBanner는 role="alert", 즉 단언적(assertive) live region으로 렌더링돼요: 동적으로 삽입된 배너(예: 실패한 요청 후 나타나는 오류)는 즉시 알려지지만, 페이지와 함께 렌더링된 배너는 전혀 알려지지 않아요. 방해하지 말아야 하는 영구적인 정보성 배너라면 속성을 전달해 role을 오버라이드하세요 — 정중한 알림에는 role="status", 순수 정적 콘텐츠에는 region 같은 landmark role(aria-label 포함)을 쓰면 돼요.
더 알아보기 (Learn more)
QBanner는 중요한 메시지와 선택적 액션(QBtn)을 표시하는 배너 요소예요. #avatar 슬롯으로 아이콘이나 이미지를, #action 슬롯으로 버튼을 넣고, inline-actions·dense·rounded 설정으로 레이아웃을 조정해요. 오프라인 경고, 결제 실패 안내 같은 공지에 적합해요.