Banner
중요한 정보를 강조하는 데 사용되는 컴포넌트예요. 사용자에게 눈에 띄어야 하는 메시지를 표시할 때 쓰입니다.
기본(Info), 톤 변형(Critical 등), 닫기(dismissible), 동작(action) 포함, 숨겨진 제목 등 다양한 예시와 전체 Props 문서를 다룹니다.
출처: 문서
본문
Banner는 중요한 정보를 강조하는 데 사용됩니다.
React 예시 (React examples)
기본 (Default)
<Banner
title="Info"
description="GitHub users are now required to enable two-factor authentication as an additional security measure."
/>
(문서 사이트에는 이 예시의 라이브 데모가 제공됩니다.)
톤 변형 (Tone variants)
Banners는 정보의 서로 다른 톤을 전달하는 데 사용할 수 있어요. 사용 사례에 맞는 올바른 변형을 선택하세요. Banner variant 지침
<Banner
aria-label="Critical"
title="Critical"
description="GitHub users are now required to enable two-factor authentication as an additional security measure."
variant="critical"
/>
닫기 가능 (Dismissible)
import React from 'react'
import {Banner, Button} from '@primer/react'
export default function Dismissable() {
const [isBannerShown, setIsBannerShown] = React.useState(true)
return isBannerShown ? (
<Banner
aria-label="Info dismissable"
title="Info"
description="GitHub users are now required to enable two-factor authentication as an additional security measure."
onDismiss={() => {
setIsBannerShown(false)
}}
/>
) : (
<Button
onClick={() => {
setIsBannerShown(true)
}}
>
Show banner again
</Button>
)
}
동작 포함 (With actions)
<Banner
aria-label="Info with actions"
title="Info"
description="GitHub users are now required to enable two-factor authentication as an additional security measure."
primaryAction={<Banner.PrimaryAction>Button</Banner.PrimaryAction>}
secondaryAction={<Banner.SecondaryAction>Button</Banner.SecondaryAction>}
/>
시각적으로 숨겨진 제목 (Visually hidden title)
Banner의 제목은 보조 기술에는 여전히 접근 가능하지만 시각적으로는 숨겨져요.
<Banner
aria-label="Info with hidden title"
title="Info"
hideTitle
description="GitHub users are now required to enable two-factor authentication as an additional security measure."
/>
추가 코드 예시 (More code examples)
Banner Storybook 스토리를 참고하세요.
Props
Banner
| 이름 | 기본값 | 설명 |
|---|---|---|
aria-label |
— | string — Banner 랜드마크 영역의 기본 이름을 오버라이드하는 선택적 라벨을 제공하세요. |
className |
— | string — Banner가 렌더링하는 가장 바깥 요소에 추가할 선택적 className을 제공하세요. |
description |
— | React.ReactNode — Banner에 대한 선택적 설명을 제공하세요. Banner에 대한 보충 정보를 제공해야 해요. |
hideTitle |
— | boolean — 제목을 시각적으로 숨길지. |
icon |
Deprecated | React.ReactNode — Banner에 대한 커스텀 아이콘을 제공하세요. variant가 info 또는 upsell일 때만 사용 가능해요. |
leadingVisual |
— | React.ReactNode — Banner에 대한 커스텀 선행 비주얼을 제공하세요. variant가 info 또는 upsell일 때만 사용 가능해요. |
onDismiss |
— | () => void — 배너가 닫힐 때 호출되는 선택적 핸들러를 제공하세요. 이 prop을 제공하면 닫기 버튼이 표시돼요. |
primaryAction |
— | React.ReactNode |
secondaryAction |
— | React.ReactNode |
title |
— | React.ReactNode — Banner의 제목. 접근 가능한 이름으로 사용되며, Banner.Title이 자식으로 사용되지 않는 한 필수예요. |
variant |
— | `'critical' |
layout |
— | `'default' |
actionsLayout |
— | `'default' |
flush |
false |
boolean — 다이얼로그, 테이블, 카드, 박스처럼 사용 가능한 공간이 제한된 제한된 공간에서 사용하기 위한 전체 너비 배너. |
Banner.Title
| 이름 | 기본값 | 설명 |
|---|---|---|
as |
— | `'h2' |
Banner.Description
| 이름 | 기본값 | 설명 |
|---|---|---|
className |
— | string — 커스텀 스타일링용 클래스 이름. |
Banner.PrimaryAction
더 많은 prop 옵션은 Button 참고.
Banner.SecondaryAction
더 많은 prop 옵션은 Button 참고.
더 알아보기 (Learn more)
- Banner 가이드라인 — 언제 어떻게 쓰는지, 변형·동작·레이아웃 규칙.
- Banner 접근성 — 피드백 배너, 라이브 리전·포커스 관리.
- Button — Banner.PrimaryAction / Banner.SecondaryAction의 기본.
- rails 구현은 Lookbook 문서를 참고하세요.