Examples
任意の長さのアラートを表示できます。オプションで閉じるボタンがあります。 適切なスタイルを設定するには、8つの required コンテキストクラスのいずれかを使用します(例: theme="success"
)
A simple primary alert—check it out!
A simple secondary alert—check it out!
A simple success alert—check it out!
A simple danger alert—check it out!
A simple warning alert—check it out!
A simple info alert—check it out!
A simple light alert—check it out!
A simple dark alert—check it out!
vue
<template>
<Alert color="primary">
A simple primary alert—check it out!
</Alert>
<Alert color="secondary">
A simple secondary alert—check it out!
</Alert>
<Alert color="success">
A simple success alert—check it out!
</Alert>
<Alert color="danger">
A simple danger alert—check it out!
</Alert>
<Alert color="warning">
A simple warning alert—check it out!
</Alert>
<Alert color="info">
A simple info alert—check it out!
</Alert>
<Alert color="light">
A simple light alert—check it out!
</Alert>
<Alert color="dark">
A simple dark alert—check it out!
</Alert>
</template>
Link color
AlertLink
コンポーネントを適用すると、リンクが適切なカラーになります。
A simple primary alert with an example link . Give it a click if you like.
A simple secondary alert with an example link . Give it a click if you like.
A simple success alert with an example link . Give it a click if you like.
A simple danger alert with an example link . Give it a click if you like.
A simple warning alert with an example link . Give it a click if you like.
A simple info alert with an example link . Give it a click if you like.
A simple light alert with an example link . Give it a click if you like.
A simple dark alert with an example link . Give it a click if you like.
vue
<template>
<Alert color="primary">
A simple primary alert with
<AlertLink>an example link</AlertLink>
. Give it a click if you like.
</Alert>
<Alert color="secondary">
A simple secondary alert with
<AlertLink>an example link</AlertLink>
. Give it a click if you like.
</Alert>
<Alert color="success">
A simple success alert with
<AlertLink>an example link</AlertLink>
. Give it a click if you like.
</Alert>
<Alert color="danger">
A simple danger alert with
<AlertLink>an example link</AlertLink>
. Give it a click if you like.
</Alert>
<Alert color="warning">
A simple warning alert with
<AlertLink>an example link</AlertLink>
. Give it a click if you like.
</Alert>
<Alert color="info">
A simple info alert with
<AlertLink>an example link</AlertLink>
. Give it a click if you like.
</Alert>
<Alert color="light">
A simple light alert with
<AlertLink>an example link</AlertLink>
. Give it a click if you like.
</Alert>
<Alert color="dark">
A simple dark alert with
<AlertLink>an example link</AlertLink>
. Give it a click if you like.
</Alert>
</template>
Additional content
アラートには、 見出し、段落、仕切りなどのHTML要素を含めることができます。
Well done!
Aww yeah, you successfully read this important alert message. This example text is going to run a bit longer so that you can see how spacing within an alert works with this kind of content.
Whenever you need to, be sure to use margin utilities to keep things nice and tidy.
vue
<template>
<Alert color="success">
<AlertHeading>Well done!</AlertHeading>
<p>
Aww yeah, you successfully read this important alert message. This example
text is going to run a bit longer so that you can see how spacing within
an alert works with this kind of content.
</p>
<hr />
<b-p margin="b-0">
Whenever you need to, be sure to use margin utilities to keep things nice
and tidy.
</b-p>
</Alert>
</template>
Icons
An example alert with an icon
vue
<template>
<Alert
color="primary"
flex
align-items="center"
>
<BIcon
icon="bi:exclamation-triangle-fill"
flex="shrink-0"
margin="e-2"
aria-label="Warning:"
/>
<div>An example alert with an icon</div>
</Alert>
</template>
同じアイコンを繰り返し簡単に参照できるようにすることもできます。NuxtIcons を使用し SVGスプライトを作成してる例をご覧ください。
An example alert with an icon
An example success alert with an icon
An example warning alert with an icon
An example danger alert with an icon
vue
<template>
<Alert
color="primary"
flex
align-items="center"
>
<BIcon
v-bootstrap
icon="bi:info-circle-fill"
color="currentColor"
flex="shrink-0"
margin="e-2"
aria-label="Info:"
/>
<div>An example alert with an icon</div>
</Alert>
<Alert
color="success"
flex
align-items="center"
>
<BIcon
icon="bi:check-circle-fill"
color="currentColor"
flex="shrink-0"
margin="e-2"
aria-label="Success:"
/>
<div>An example success alert with an icon</div>
</Alert>
<Alert
color="warning"
flex
align-items="center"
>
<BIcon
icon="bi:exclamation-triangle-fill"
color="currentColor"
flex="shrink-0"
margin="e-2"
aria-label="Warning:"
/>
<div>An example warning alert with an icon</div>
</Alert>
<Alert
color="danger"
flex
align-items="center"
>
<BIcon
icon="bi:exclamation-triangle-fill"
color="currentColor"
flex="shrink-0"
margin="e-2"
aria-label="Danger:"
/>
<div>An example danger alert with an icon</div>
</Alert>
</template>
Dismissing
CloseButton
コンポーネント を使用すると、アラートインラインを消すことができます。
ライブデモを見ることができます:
Holy guacamole! You should check in on some of those fields below.
vue
<template>
<Alert
color="warning"
dismissible
fade
>
<strong>Holy guacamole!</strong>
You should check in on some of those fields below.
<CloseButton dismiss="alert" />
</Alert>
</template>
Triggers
解除は、以下に示すように、アラート内のボタンのdismiss属性で行うことができます。
Holy guacamole! You should check in on some of those fields below.
vue
<template>
<Alert
color="warning"
dismissible
fade
>
<b-button
color="primary"
dismiss="alert"
>
Close
</b-button>
<strong>Holy guacamole!</strong>
You should check in on some of those fields below.
<CloseButton dismiss="alert" />
</Alert>
</template>
または、以下のようにtargetを使用してアラートの外側のボタンに表示します。
Holy guacamole! You should check in on some of those fields below.
vue
<template>
<Alert
id="my-alert"
color="warning"
dismissible
fade
>
<strong>Holy guacamole!</strong>
You should check in on some of those fields below.
</Alert>
<b-button
color="primary"
dismiss="alert"
target="#my-alert"
>
Close
</b-button>
</template>
Methods
Method | Description |
---|---|
toggle | 手動で切り替えます |
show | 手動で開きます |
hide | 手動で非表示にします |