Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit492a20b

Browse files
committed
docs(CAlert): update content
1 parent812ffc4 commit492a20b

11 files changed

+381
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
title:React Alert Component API
3+
name:Alert API
4+
description:Explore the API reference for the React Alert component and discover how to effectively utilize its props for customization.
5+
route:/components/alert/
6+
---
7+
8+
importCAlertAPIfrom'../../api/CAlert.api.mdx'
9+
importCAlertHeadingAPIfrom'../../api/CAlertHeading.api.mdx'
10+
importCAlertLinkAPIfrom'../../api/CAlertLink.api.mdx'
11+
12+
##CAlert
13+
14+
<CAlertAPI />
15+
16+
##CAlertHeading
17+
18+
<CAlertHeadingAPI />
19+
20+
##CAlertLink
21+
22+
<CAlertLinkAPI />
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
importReactfrom'react'
2+
import{CAlert,CAlertHeading}from'@coreui/react'
3+
4+
exportconstAlertAdditionalContentExample=()=>{
5+
return(
6+
<CAlertcolor="success">
7+
<CAlertHeadingas="h4">Well done!</CAlertHeading>
8+
<p>
9+
Aww yeah, you successfully read this important alert message. This example text is going to
10+
run a bit longer so that you can see how spacing within an alert works with this kind of
11+
content.
12+
</p>
13+
<hr/>
14+
<pclassName="mb-0">
15+
Whenever you need to, be sure to use margin utilities to keep things nice and tidy.
16+
</p>
17+
</CAlert>
18+
)
19+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
importReactfrom'react'
2+
import{CAlert}from'@coreui/react'
3+
4+
exportconstAlertDismissingExample=()=>{
5+
return(
6+
<CAlert
7+
color="warning"
8+
dismissible
9+
onClose={()=>{
10+
alert('👋 Well, hi there! Thanks for dismissing me.')
11+
}}
12+
>
13+
<strong>Go right ahead</strong> and click that dimiss over there on the right.
14+
</CAlert>
15+
)
16+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
importReactfrom'react'
2+
import{CAlert}from'@coreui/react'
3+
4+
exportconstAlertExample=()=>{
5+
return(
6+
<>
7+
<CAlertcolor="primary">A simple primary alert—check it out!</CAlert>
8+
<CAlertcolor="secondary">A simple secondary alert—check it out!</CAlert>
9+
<CAlertcolor="success">A simple success alert—check it out!</CAlert>
10+
<CAlertcolor="danger">A simple danger alert—check it out!</CAlert>
11+
<CAlertcolor="warning">A simple warning alert—check it out!</CAlert>
12+
<CAlertcolor="info">A simple info alert—check it out!</CAlert>
13+
<CAlertcolor="light">A simple light alert—check it out!</CAlert>
14+
<CAlertcolor="dark">A simple dark alert—check it out!</CAlert>
15+
</>
16+
)
17+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
importReactfrom'react'
2+
import{CAlert}from'@coreui/react'
3+
4+
exportconstAlertIcons1Example=()=>{
5+
return(
6+
<CAlertcolor="primary"className="d-flex align-items-center">
7+
<svgclassName="flex-shrink-0 me-2"width="24"height="24"viewBox="0 0 512 512">
8+
<rect
9+
width="32"
10+
height="176"
11+
x="240"
12+
y="176"
13+
fill="var(--ci-primary-color, currentColor)"
14+
className="ci-primary"
15+
></rect>
16+
<rect
17+
width="32"
18+
height="32"
19+
x="240"
20+
y="384"
21+
fill="var(--ci-primary-color, currentColor)"
22+
className="ci-primary"
23+
></rect>
24+
<path
25+
fill="var(--ci-primary-color, currentColor)"
26+
d="M274.014,16H237.986L16,445.174V496H496V445.174ZM464,464H48V452.959L256,50.826,464,452.959Z"
27+
className="ci-primary"
28+
></path>
29+
</svg>
30+
<div>An example alert with an icon</div>
31+
</CAlert>
32+
)
33+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
importReactfrom'react'
2+
import{CAlert}from'@coreui/react'
3+
importCIconfrom'@coreui/icons-react'
4+
import{cilBurn,cilCheckCircle,cilInfo,cilWarning}from'@coreui/icons'
5+
6+
exportconstAlertIcons2Example=()=>{
7+
return(
8+
<>
9+
<CAlertcolor="primary"className="d-flex align-items-center">
10+
<CIconicon={cilInfo}className="flex-shrink-0 me-2"width={24}height={24}/>
11+
<div>An example alert with an icon</div>
12+
</CAlert>
13+
<CAlertcolor="success"className="d-flex align-items-center">
14+
<CIconicon={cilCheckCircle}className="flex-shrink-0 me-2"width={24}height={24}/>
15+
<div>An example success alert with an icon</div>
16+
</CAlert>
17+
<CAlertcolor="warning"className="d-flex align-items-center">
18+
<CIconicon={cilWarning}className="flex-shrink-0 me-2"width={24}height={24}/>
19+
<div>An example warning alert with an icon</div>
20+
</CAlert>
21+
<CAlertcolor="danger"className="d-flex align-items-center">
22+
<CIconicon={cilBurn}className="flex-shrink-0 me-2"width={24}height={24}/>
23+
<div>An example danger alert with an icon</div>
24+
</CAlert>
25+
</>
26+
)
27+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
importReactfrom'react'
2+
import{CAlert,CAlertLink}from'@coreui/react'
3+
4+
exportconstAlertLinkColorExample=()=>{
5+
return(
6+
<>
7+
<CAlertcolor="primary">
8+
A simple primary alert with<CAlertLinkhref="#">an example link</CAlertLink>. Give it a
9+
click if you like.
10+
</CAlert>
11+
<CAlertcolor="secondary">
12+
A simple secondary alert with<CAlertLinkhref="#">an example link</CAlertLink>. Give it a
13+
click if you like.
14+
</CAlert>
15+
<CAlertcolor="success">
16+
A simple success alert with<CAlertLinkhref="#">an example link</CAlertLink>. Give it a
17+
click if you like.
18+
</CAlert>
19+
<CAlertcolor="danger">
20+
A simple danger alert with<CAlertLinkhref="#">an example link</CAlertLink>. Give it a
21+
click if you like.
22+
</CAlert>
23+
<CAlertcolor="warning">
24+
A simple warning alert with<CAlertLinkhref="#">an example link</CAlertLink>. Give it a
25+
click if you like.
26+
</CAlert>
27+
<CAlertcolor="info">
28+
A simple info alert with<CAlertLinkhref="#">an example link</CAlertLink>. Give it a click
29+
if you like.
30+
</CAlert>
31+
<CAlertcolor="light">
32+
A simple light alert with<CAlertLinkhref="#">an example link</CAlertLink>. Give it a click
33+
if you like.
34+
</CAlert>
35+
<CAlertcolor="dark">
36+
A simple dark alert with<CAlertLinkhref="#">an example link</CAlertLink>. Give it a click
37+
if you like.
38+
</CAlert>
39+
</>
40+
)
41+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
importReact,{useState}from'react'
2+
import{CAlert,CButton}from'@coreui/react'
3+
4+
exportconstAlertLiveExample=()=>{
5+
const[visible,setVisible]=useState(false)
6+
return(
7+
<>
8+
<CAlertcolor="primary"dismissiblevisible={visible}onClose={()=>setVisible(false)}>
9+
A simple primary alert—check it out!
10+
</CAlert>
11+
<CButtoncolor="primary"onClick={()=>setVisible(true)}>
12+
Show live alert
13+
</CButton>
14+
</>
15+
)
16+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
importReactfrom'react'
2+
import{CAlert}from'@coreui/react'
3+
4+
exportconstAlertSolidExample=()=>{
5+
return(
6+
<>
7+
<CAlertcolor="primary"variant="solid">
8+
A simple solid primary alert—check it out!
9+
</CAlert>
10+
<CAlertcolor="secondary"variant="solid">
11+
A simple solid secondary alert—check it out!
12+
</CAlert>
13+
<CAlertcolor="success"variant="solid">
14+
A simple solid success alert—check it out!
15+
</CAlert>
16+
<CAlertcolor="danger"variant="solid">
17+
A simple solid danger alert—check it out!
18+
</CAlert>
19+
<CAlertcolor="warning"variant="solid">
20+
A simple solid warning alert—check it out!
21+
</CAlert>
22+
<CAlertcolor="info"variant="solid">
23+
A simple solid info alert—check it out!
24+
</CAlert>
25+
<CAlertcolor="light"variant="solid"className="text-high-emphasis">
26+
A simple solid light alert—check it out!
27+
</CAlert>
28+
<CAlertcolor="dark"variant="solid">
29+
A simple solid dark alert—check it out!
30+
</CAlert>
31+
</>
32+
)
33+
}
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
---
2+
title:React Alert Component
3+
name:Alert
4+
description:React alert component gives contextual feedback information for common user operations. The alert component is delivered with a bunch of usable and adjustable alert messages.
5+
menu:Components
6+
route:/components/alert/
7+
other_frameworks:alert
8+
---
9+
10+
##How to use React Alert Component.
11+
12+
React Alert is prepared for any length of text, as well as an optional close button. For a styling, use one of the**required** contextual`color` props (e.g.,`primary`). For inline dismissal, use the[dismissing prop](#dismissing).
13+
14+
import {AlertExample }from'./examples/AlertExample.tsx'
15+
importAlertExampleTSfrom'!!raw-loader!./examples/AlertExample.tsx'
16+
17+
<ExampleSnippetcode={AlertExampleTS}componentName="React Alert">
18+
<AlertExample />
19+
</ExampleSnippet>
20+
21+
<Calloutcolor="info"title="Conveying meaning to assistive technologies">
22+
Using color to add meaning only provides a visual indication, which will not be conveyed to
23+
users of assistive technologies – such as screen readers. Ensure that information denoted by the
24+
color is either obvious from the content itself (e.g. the visible text), or is included through
25+
alternative means, such as additional text hidden with the`.visually-hidden` class.
26+
</Callout>
27+
28+
###Live example
29+
30+
Click the button below to show an alert (hidden with inline styles to start), then dismiss (and destroy) it with the built-in close button.
31+
32+
import {AlertLiveExample }from'./examples/AlertLiveExample.tsx'
33+
importAlertLiveExampleTSfrom'!!raw-loader!./examples/AlertLiveExample.tsx'
34+
35+
<ExampleSnippetcode={AlertLiveExampleTS}componentName="React Alert">
36+
<AlertLiveExample />
37+
</ExampleSnippet>
38+
39+
###Link color
40+
41+
Use the`<CAlertLink>` component to immediately give matching colored links inside any react alert component.
42+
43+
import {AlertLinkColorExample }from'./examples/AlertLinkColorExample.tsx'
44+
importAlertLinkColorExampleTSfrom'!!raw-loader!./examples/AlertLinkColorExample.tsx'
45+
46+
<ExampleSnippetcode={AlertLinkColorExampleTS}componentName="React Alert">
47+
<AlertLinkColorExample />
48+
</ExampleSnippet>
49+
50+
###Additional content
51+
52+
React Alert can also incorporate supplementary components&amp; elements like heading, paragraph, and divider.
53+
54+
import {AlertAdditionalContentExample }from'./examples/AlertAdditionalContentExample.tsx'
55+
importAlertAdditionalContentExampleTSfrom'!!raw-loader!./examples/AlertAdditionalContentExample.tsx'
56+
57+
<ExampleSnippetcode={AlertAdditionalContentExampleTS}componentName="React Alert">
58+
<AlertAdditionalContentExample />
59+
</ExampleSnippet>
60+
61+
###Icons
62+
63+
Similarly, you can use[flexbox utilities](https//coreui.io/docs/4.0/utilities/flex") and[CoreUI Icons](https://icons.coreui.io) to create react alerts with icons. Depending on your icons and content, you may want to add more utilities or custom styles.
64+
65+
import {AlertIcons1Example }from'./examples/AlertIcons1Example.tsx'
66+
importAlertIcons1ExampleTSfrom'!!raw-loader!./examples/AlertIcons1Example.tsx'
67+
68+
<ExampleSnippetcode={AlertIcons1ExampleTS}componentName="React Alert">
69+
<AlertIcons1Example />
70+
</ExampleSnippet>
71+
72+
73+
Need more than one icon for your react alerts? Consider using[CoreUI Icons](https://icons.coreui.io).
74+
75+
import {AlertIcons2Example }from'./examples/AlertIcons2Example.tsx'
76+
importAlertIcons2ExampleTSfrom'!!raw-loader!./examples/AlertIcons2Example.tsx'
77+
78+
<ExampleSnippetcode={AlertIcons2ExampleTS}componentName="React Alert">
79+
<AlertIcons2Example />
80+
</ExampleSnippet>
81+
82+
83+
###Solid
84+
85+
Use`variant="solid"` to change contextual colors to solid.
86+
87+
import {AlertSolidExample }from'./examples/AlertSolidExample.tsx'
88+
importAlertSolidExampleTSfrom'!!raw-loader!./examples/AlertSolidExample.tsx'
89+
90+
<ExampleSnippetcode={AlertSolidExampleTS}componentName="React Alert">
91+
<AlertSolidExample />
92+
</ExampleSnippet>
93+
94+
###Dismissing
95+
96+
React Alert component can also be easily dismissed. Just add the`dismissible` prop.
97+
98+
import {AlertDismissingExample }from'./examples/AlertDismissingExample.tsx'
99+
importAlertDismissingExampleTSfrom'!!raw-loader!./examples/AlertDismissingExample.tsx'
100+
101+
<ExampleSnippetcode={AlertDismissingExampleTS}componentName="React Alert">
102+
<AlertDismissingExample />
103+
</ExampleSnippet>
104+
105+
106+
<Calloutcolor="warning">
107+
When an alert is dismissed, the element is completely removed from the page structure. If a
108+
keyboard user dismisses the alert using the close button, their focus will suddenly be lost and,
109+
depending on the browser, reset to the start of the page/document.
110+
</Callout>
111+
112+
##API
113+
114+
Check out the documentation below for a comprehensive guide to all the props you can use with the components mentioned here.
115+
116+
-[&lt;CAlert /&gt;](./api/#calert)
117+
-[&lt;CAlertHeading /&gt;](./api/#calertheading)
118+
-[&lt;CAlertLink /&gt;](./api/#calertlink)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
title:React Alert Component Styling
3+
name:Alert Styling
4+
description:Learn how to customize the React Alert component with CSS classes, variables, and SASS for flexible styling and seamless integration into your design.
5+
route:/components/alert/
6+
---
7+
8+
###CSS class names
9+
10+
React Alert comes with built-in class names that make styling super simple. Here’s a quick rundown of what you can use:
11+
12+
<ClassNamesDocs
13+
files={[
14+
'components/alert/CAlert.tsx',
15+
'components/alert/CAlertHeading.tsx',
16+
'components/alert/CAlertLink.tsx',
17+
]}
18+
/>
19+
20+
###CSS variables
21+
22+
React Alert supports CSS variables for easy customization. These variables are set via SASS but allow direct overrides in your stylesheets or inline styles.
23+
24+
<ScssDocsfile="_alert.scss"capture="alert-css-vars" />
25+
26+
####How to use CSS variables
27+
28+
```jsx
29+
constcustomVars= {
30+
'--cui-alert-color':'#333',
31+
'--cui-alert-bg':'#f8f9fa',
32+
}
33+
34+
return<CAlert style={customVars}>{/* Alert content*/}</CAlert>
35+
```
36+
37+
###SASS variables
38+
39+
<ScssDocsfile="_variables.scss"capture="alert-variables" />

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp