インポート
コードをコピー
import { Alert } from '@k8ordo/ui';使い方
縦書きプレビューに切り替え
情報
コードをコピー
<Alert message="This is an info alert." tone="info" />トーン
縦書きプレビューに切り替え
成功
情報
警告
エラー
コードをコピー
<Alert message="Operation completed successfully." tone="success" />
<Alert message="Here is some useful information." tone="info" />
<Alert message="Please proceed with caution." tone="warning" />
<Alert message="Something went wrong." tone="error" />複数のメッセージ
縦書きプレビューに切り替え
エラー
- Password must be at least 8 characters.
- Password must include a number.
- Password must include a special character.
コードをコピー
<Alert
message={[
"Password must be at least 8 characters.",
"Password must include a number.",
"Password must include a special character.",
]}
tone="error"
/>操作のリンク
縦書きプレビューに切り替え
情報
警告
コードをコピー
// Navigation link — the consumer owns the element and its style.
// Use Anchor for a link that matches the library look, or any
// <a> / Next.js Link with your own className.
<Alert
message="A new version is available."
tone="info"
action={{
label: 'Learn more',
renderItem: ({ children }) => (
<Anchor href="https://example.com" openInNewTab>
{children}
</Anchor>
),
}}
/>
// Action button (open a modal, etc.) — style it however you like.
<Alert
message="Your profile setup is incomplete."
tone="warning"
action={{
label: 'Open settings',
renderItem: ({ children }) => (
<button
className={styles.link}
type="button"
onClick={() => {}}
>
{children}
</button>
),
}}
/>閉じられるアラート
縦書きプレビューに切り替え
警告
警告
コードをコピー
const [isVisible, setIsVisible] = useState(true);
// onClose renders an in-frame close (×) button at the row's end.
<Alert
message="..."
onClose={() => setIsVisible(false)}
tone="warning"
/>
// onClose can be combined with action.
<Alert
action={{
label: 'Learn more',
renderItem: ({ children }) => (
<button className={styles.link} type="button" onClick={openHelp}>
{children}
</button>
),
}}
message="..."
onClose={() => setIsVisible(false)}
tone="warning"
/>Props
message- Type:
string|string[] - Default: -
tone- Type:
Status - Default: -
action?- Type:
AlertAction - Default: -
closeLabel?- Type:
string - Default: -
onClose?- Type:
() => void - Default: -
| Prop | Type | Default |
|---|---|---|
message | string|string[] | - |
tone | Status | - |
action? | AlertAction | - |
closeLabel? | string | - |
onClose? | () => void | - |
継承する属性(内部で固定するものを除く): HTMLAttributes<HTMLDivElement>
ラベルやプレースホルダーなど、このコンポーネントが描く文言は、propsで指定しないと文言辞書から読まれます。差し替え方は次を見てください: コンポーネントの文言