Vai al contenuto principale

Panoramica

Banner dispone il contenuto fornito dal chiamante, un nodo icon facoltativo e un nodo action facoltativo. status descrive il significato del feedback: neutral, info, success, warning o error. variant seleziona l’aspetto solid o soft. Un valore color esplicito sostituisce la palette dello stato senza modificarne il significato. I valori predefiniti sono status="info" e variant="solid". Le palette di stato predefinite sono rispettivamente grigia, blu, verde, arancione e rossa.

Utilizzo

Azioni e aspetto

Banner.Action fornisce un piccolo pulsante con contorno che eredita il colore visualizzato del banner, incluse le sostituzioni esplicite della palette e gli aspetti solidi. Supporta interazioni Button, collegamenti, ref e rendering personalizzato. Lo slot action accetta anche controlli arbitrari. L’elemento radice è un div. Gli attributi nativi, i gestori di eventi, className, style e ref si applicano a tale radice. render accetta un elemento Base UI o una callback; la callback riceve props nativi e ref, oltre allo stato risolto di status, variant e color. Mantieni i props e ref forniti quando componi un altro elemento.
Lo stato non assegna automaticamente role, aria-live o annunci. Sceglili nel chiamante quando gli aggiornamenti devono essere annunciati. Fornisci nomi accessibili per i controlli e contrassegna i nodi delle icone decorative con aria-hidden. Il chiamante gestisce la visibilità e la chiusura.

Chiusura

Passa onDismiss per visualizzare un controllo di chiusura ghost da 24 px all’estremità logica in linea. Il controllo eredita il colore del banner e ha type="button". Per impostazione predefinita, closeLabel è Close; fornisci testo localizzato nella tua applicazione. Una spaziatura in linea equilibrata mantiene il contenuto centrato e le azioni ben distanti dal controllo. Il chiamante gestisce la visibilità. L’attivazione del controllo di chiusura chiama onDismiss e lascia il banner montato finché il chiamante non aggiorna lo stato. Le altre azioni rimangono nello slot action.

Migrazione

Sostituisci variant="primary" con variant="solid" e variant="secondary" con variant="soft". Sostituisci color="danger" con status="error", oppure con color="red" quando deve cambiare solo la palette. I banner informativi blu possono usare status="info".

Props

ReactNode
Optional trailing ReactNode. Banner.Action supplies a small outline action that inherits the resolved banner color; arbitrary controls are also accepted.
ReactNode
Caller-provided content, including text, links and controls.
string
Class merged onto the root div or composed element.
string
predefinito:"Close"
Accessible label for the close control. Defaults to Close; supply localized text when needed.
"blue" | "gray" | "green" | "orange" | "red"
predefinito:"status palette"
Palette override: gray, blue, green, orange or red. When omitted, status selects the corresponding palette.
ReactNode
Optional leading ReactNode. The caller supplies decorative or accessible icon semantics.
(() => void)
Renders a 24px ghost close control and calls this callback when activated. The caller owns visibility.
Ref<HTMLDivElement>
Ref to the root div, or to the DOM element supplied through render.
ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, BannerState>
Base UI element or render callback. The callback receives native props/ref and resolved status, variant and color state.
"error" | "info" | "neutral" | "success" | "warning"
predefinito:"info"
Feedback meaning: neutral, info, success, warning or error. Defaults to info. Does not assign a role or live region.
CSSProperties
Inline styles applied to the root div or composed element.
"soft" | "solid"
predefinito:"solid"
Solid or soft appearance. Defaults to solid, independently of status.
string | ((state: ButtonState) => string | undefined)
CSS class applied to the element, or a function that returns a class based on the component’s state.
boolean
Adds a shadow and backdrop blur. Neutral outline buttons also use elevated surface colors.
ReactNode
Decorative content displayed after the label.
boolean
predefinito:"false"
Whether the button should be focusable when disabled.
boolean
Expands the button to fill its container width.
string
Destination URL. Renders a native anchor when render is omitted unless nativeButton is explicitly true. Custom renderers retain their own element contract.
boolean
Shows a loading indicator and disables activation.
"center" | "end" | "start"
Where the loading indicator appears. center hides the content while preserving its layout space; start and end keep children and the opposite icon visible and replace the corresponding icon with the spinner.
boolean
predefinito:"true"
Whether the rendered root is a native button. Defaults to true for custom renderers. The built-in href anchor defaults to false; an explicit value takes precedence.
ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ButtonState>
Caller-supplied root element or renderer. Native attributes, handlers, event details, and refs reach the rendered root. Use nativeButton={false} and role="link" for a custom navigation anchor. Router integration belongs to the caller.
AriaRole
Role of the root element. Use link for custom navigation renderers.
ShortcutDefinition
Flat key array for simultaneous keys, or nested key arrays for an ordered sequence. Displayed on non-mobile screens.
string
Localized text between sequence steps. Defaults to then.
ReactNode
Decorative content displayed before the label.
CSSProperties | ((state: ButtonState) => CSSProperties | undefined)
Style applied to the element, or a function that returns a style object based on the component’s state.