JGuang

NoticeBar

NoticeBar · Ant Design Mobile

Preview
npm install antd-mobile@5.43.0

NoticeBar

Displays a set of message notifications.

Install

npm install antd-mobile@5.43.0

antd-mobile is for mobile web, not React Native or Mini Programs. React 19 projects must register createRoot with unstableSetRender at the entry, or imperative APIs such as Toast and Dialog cannot render. Switch dark mode with <html data-prefers-color-scheme="dark">.

Examples come from the official Ant Design Mobile repository (MIT) at the commit published as npm 5.43.0. Presentation helpers such as DemoBlock are JGuang rewrites, not antd-mobile APIs.

Displays a set of message notifications.

When to Use

It is applicable to the notification of information in the current page, which is a more conspicuous in-page notification method.

Demos

NoticeBar

Props

NameDescriptionTypeDefaultVersion
closeableWhether it can be closedbooleanfalse
closeIconCustom close button iconReactNode<CloseOutline />
colorThe type of the NoticeBar'default' | 'alert' | 'error' | 'info' | 'success''default'
contentThe content of the NoticeBarReact.ReactNode-
delayDelay to start scrolling, unit msnumber2000
extraAdditional operating area, displayed to the left of the close buttonReact.ReactNode-
iconRadio icon on the leftReact.ReactNode<SoundOutline />
onCloseCallback when closed() => void-
onClickClick event() => void-
speedScroll speed, unit px/snumber50
wrapWhether to display multiple linesbooleanfalse
shapeShape of the NoticeBar (rectangular: sharp; neutral: round corner; rounded: circle/pill shape)'rectangular' | 'neutral' | 'rounded''rectangular'5.38.0
borderedBorder visibility of the NoticeBar (block: top and bottom border; true: full border; false: no border)'block' | boolean'block'5.38.0

CSS Variables

NameDescriptionDefaultGlobalVersion
--background-colorbackground colorvar(--adm-color-weak)
--border-colorborder colorvar(--adm-color-weak)
--font-sizeFont size of notice text content.15px
--heightHeight of the whole element.40px
--icon-font-sizeFont size of left icon.18px
--text-colortext color#ffffff
--adm-notice-bar-border-radiusBorder radius of neutral shape NoticeBar4px--adm-notice-bar-border-radius5.38.0
--adm-notice-bar-border-widthBorder width of bordered NoticeBar1px--adm-notice-bar-border-width5.38.0