Ir al contenido
Español

Cómo funciona

Every colour is mixed from one --_tone per variant, so a brand palette needs only the four --ds tone tokens. Dismissal animates grid-template-rows from 1fr to 0fr together with opacity and margins, then calls onDismiss, so the layout below closes the gap without a jump.

Úsalo para

  • Persistent context on a page: a trial ending, a failed payment, a verified setting.
  • Messages that belong next to the content they are about.

Busca otra opción cuando

  • Feedback for an action that just happened: use a toast or snackbar.
  • Field errors: show them under the field.

Uso

import { Callout } from './Callout.jsx'

export function TrialNotice({ onHide }) {
  return (
    <Callout
      tone="warning"
      title="Trial ends in 3 days"
      onDismiss={onHide}
      actions={
        <>
          <button type="button" data-primary>Choose a plan</button>
          <button type="button">Remind me later</button>
        </>
      }
    >
      Pick a plan to keep your projects and members.
    </Callout>
  )
}

Propiedades

PropiedadTipoPor defectoQué hace
tone'info' | 'success' | 'warning' | 'danger''info'Colour and default icon.
variant'soft' | 'outline''soft'Tinted surface, or a plain surface with a tinted border.
titleReactNode—One short line.
childrenReactNode—The body text.
actionsReactNode—Buttons or links; they are styled as tinted text links, and data-primary makes one a filled button.
iconReactNode | false—Replace the tone icon, or false to hide it.
onDismiss() => void—Shows a close button; called after the collapse finishes.
dismissLabelstring'Dismiss'Accessible name of the close button.
livebooleanfalseAnnounce it: role alert for warning and danger, status otherwise. Off, it is a role note.

Accesibilidad

  • By default the box is a role note; with live it becomes role alert (warning, danger) or status (info, success) so it is announced.
  • Tone is carried by an icon and the wording as well as colour.
  • The dismiss button has an accessible name and a 32px target; actions have 32px tall hit areas and focus rings.
  • With reduced motion it disappears at once.

Movimiento

Dismiss: grid rows and margins 320ms cubic-bezier(0.65, 0, 0.35, 1), opacity 200ms.

Añádelo a tu proyecto

Copia la instrucción en Codex o Claude Code. El agente lee el código publicado, te muestra lo que va a escribir y añade el componente junto a los tuyos.

Callout.jsxcallout.csstokens.cssREADME.md

Los dos archivos se instalan juntos. La hoja de estilos lee las variables de tokens.css y lleva valores de reserva, así que también funciona sola.

Avisos
Lluvia de confeti viene con Pro. La vista previa aparece al desbloquearlo.
Indicador de actividad viene con Pro. La vista previa aparece al desbloquearlo.