Alert
アイコン、タイトル、アクションを持つインラインの状態メッセージです。
Heads up
The plugin injects RefineUI styles for you.
Review before publishing
Two pages have no description.
インポート
「インポート」セクションimport { Alert, AlertRow, AlertIcon, AlertBody, AlertTitle, AlertDescription, AlertClose, AlertActions, AlertAction,} from "@pelagornis/page/components";上のプレビューはこのファイルを描画したものです。src/components/ にコピーして使い始めてください。
import { Alert, AlertAction, AlertActions, AlertBody, AlertClose, AlertDescription, AlertIcon, AlertRow, AlertTitle, Stack,} from "@pelagornis/page/components";
export default function AlertDemo() { return ( <Stack gap="sizeMedium" className="w-full"> <Alert variant="info"> <AlertRow> <AlertIcon /> <AlertBody> <AlertTitle>Heads up</AlertTitle> <AlertDescription>The plugin injects RefineUI styles for you.</AlertDescription> </AlertBody> </AlertRow> </Alert> <Alert variant="warning"> <AlertRow> <AlertIcon /> <AlertBody> <AlertTitle>Review before publishing</AlertTitle> <AlertDescription>Two pages have no description.</AlertDescription> </AlertBody> <AlertClose type="button" /> </AlertRow> <AlertActions> <AlertAction type="button">Review</AlertAction> </AlertActions> </Alert> </Stack> );}MDX で使う
「MDX で使う」セクションAlert は React の状態を共有する複数のパーツで構成されます。MDX に書いた子要素はそれぞれ別のアイランドとして描画されるため、パーツ同士がつながりません。上の例のように .tsx ファイルで組み立て、そのファイルをインポートしてください。
---title: Example---
import AlertExample from "../../components/AlertExample";
<AlertExample client:load />client:load はページの読み込み時にアイランドをハイドレートします。ページの下の方にあるコンテンツには client:visible を使ってください。
Markdoc で使う
「Markdoc で使う」セクションMarkdoc のタグは Astro コンポーネントを描画しますが、このコンポーネントにはクライアントの状態が必要です。例をハイドレートする .astro ファイルで包み、そのファイルをタグとして登録してください。
---import AlertExample from "../AlertExample";---
<AlertExample client:load />import { component, defineMarkdocConfig } from "@astrojs/markdoc/config";import starlightMarkdoc from "@astrojs/starlight-markdoc";import pageMarkdoc from "@pelagornis/page/markdoc";
export default defineMarkdocConfig({ extends: [starlightMarkdoc(), pageMarkdoc()], tags: { "alert-example": { render: component("./src/components/markdoc/AlertExample.astro"), selfClosing: true, }, },});{% alert-example /%}バリアント
「バリアント」セクション各 variant prop が受け付ける値です。
| Prop | 値 |
|---|---|
variant | default info success warning danger custom |
コンポーネントを構成するパーツと、それぞれが描画する data-refineui のロールです。
| パーツ | ロール |
|---|---|
root | alert |
icon | alert-icon |
content | alert-content |
row | alert-row |
body | alert-body |
title | alert-title |
description | alert-description |
actions | alert-actions |
action | alert-action |
close | alert-close |
コンポーネントがスタイルを当てる状態です。コンポーネントの状態は data 属性として公開されます。
| 種類 | 状態 |
|---|---|
| 疑似クラス | focus-visible |
- デザインのガイドとトークンの詳細は RefineUI · Alert を参照してください。
- 共通のルールは MDX で使う と Markdoc で使う を参照してください。