@k8ordo/ui

Callout

本文の中に置く注記です。補足や落とし穴を、段落やコードを含めて書けます。

インポート

ts
import { Callout } from '@k8ordo/ui';

使い方

情報

Note

Values stay in the DOM, so typing never re-renders.

tsx
<Callout label="Note" tone="info">
  <p>Values stay in the DOM, so typing never re-renders.</p>
</Callout>

トーン

成功

Supported

Works in every core browser.

情報

Note

The browser checks the input before it is sent.

警告

Pitfall

A controlled field is not restored by a form reset.

エラー

Deprecated

This option goes away in the next major.

tsx
<Callout label="Supported" tone="success">…</Callout>
<Callout label="Note" tone="info">…</Callout>
<Callout label="Pitfall" tone="warning">…</Callout>
<Callout label="Deprecated" tone="error">…</Callout>

本文のコードとリンク

本文はchildrenなので、段落を重ねたりCodeやAnchorを入れたりできます。labelを省くと、アイコンと本文だけになります。

警告

Pitfall

Passing value makes the field controlled, and a form reset no longer restores it.

Pass defaultValue instead. See the input reference.

情報

This article reflects the API as of July 2023.

tsx
<Callout label="Pitfall" tone="warning">
  <p>
    Passing <Code>value</Code> makes the field controlled, and a form
    reset no longer restores it.
  </p>
  <p>
    Pass <Code>defaultValue</Code> instead. See{' '}
    <Anchor href="https://react.dev/reference/react-dom/components/input">
      the input reference
    </Anchor>
    .
  </p>
</Callout>

<Callout tone="info">
  <p>This article reflects the API as of July 2023.</p>
</Callout>

Alertとの使い分け

Alertは操作の結果やアプリの状態を知らせ、表示されるとスクリーンリーダーが読み上げます。記事やガイドの本文に置く補足にはCalloutを使います。role="note"なので、ページの読み込みやクライアントでの遷移で差し込まれても読み上げられません。

Props

children
Type: ReactNode
Default: -
tone
Type: Status
Default: -
label?
Type: string
Default: -
PropTypeDefault
childrenReactNode-
toneStatus-
label?string-

継承する属性(内部で固定するものを除く): HTMLAttributes<HTMLDivElement>

ラベルやプレースホルダーなど、このコンポーネントが描く文言は、propsで指定しないと文言辞書から読まれます。差し替え方は次を見てください: コンポーネントの文言

k8ordo

Baselineに入った機能を、制限なく使うReactのライブラリ群。