本文へ移動
日本語

仕組み

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.

向いている場面

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

向かない場面

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

使い方

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>
  )
}

プロパティ

プロパティ型既定値説明
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.

アクセシビリティ

  • 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.

モーション

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

プロジェクトに追加

プロンプトを Codex または Claude Code に貼り付けます。エージェントが公開ソースを読み、書き込む内容を示したうえで、既存のコンポーネントの隣に追加します。

Callout.jsxcallout.csstokens.cssREADME.md

2 つのファイルを一緒に導入します。スタイルは tokens.css の変数を読み、予備の値も持つため、単体でも表示できます。

フィードバック
「紙吹雪」は Pro に含まれます。解除するとプレビューが表示されます。
「ライブステータスピル」は Pro に含まれます。解除するとプレビューが表示されます。