@fpkit/acss 3.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/libs/{chunk-2NRIP6RB.cjs → chunk-2C3YLBWP.cjs} +3 -3
- package/libs/{chunk-NWJDAHP6.cjs → chunk-2GJHKWEK.cjs} +3 -3
- package/libs/{chunk-FVROL3V5.js → chunk-2JCDEC32.js} +3 -3
- package/libs/{chunk-IRLFZ3OL.js → chunk-3XJC4XUG.js} +2 -2
- package/libs/{chunk-23ANBDCR.js → chunk-4I5MF54P.js} +3 -3
- package/libs/chunk-4I5MF54P.js.map +1 -0
- package/libs/chunk-5CJPTDK3.cjs +31 -0
- package/libs/chunk-5CJPTDK3.cjs.map +1 -0
- package/libs/{chunk-E4OSROCA.cjs → chunk-5QSNJQVH.cjs} +3 -3
- package/libs/{chunk-O3JIHC5M.cjs → chunk-6BUJZ4DJ.cjs} +3 -3
- package/libs/{chunk-WXBFBWYF.cjs → chunk-AFINOD2L.cjs} +3 -3
- package/libs/{chunk-HRRHPLER.js → chunk-AWZLSWDO.js} +2 -2
- package/libs/chunk-DDSXKOUB.js +7 -0
- package/libs/chunk-DDSXKOUB.js.map +1 -0
- package/libs/{chunk-CWRNJA4P.js → chunk-DIJBIOFE.js} +3 -3
- package/libs/chunk-EJ6KYBFE.cjs +13 -0
- package/libs/chunk-EJ6KYBFE.cjs.map +1 -0
- package/libs/{chunk-GUJSMQ3V.cjs → chunk-EKJYOCLY.cjs} +3 -3
- package/libs/{chunk-X5RKCLDC.cjs → chunk-F64GE6RG.cjs} +4 -4
- package/libs/chunk-FMIM3332.js +8 -0
- package/libs/chunk-FMIM3332.js.map +1 -0
- package/libs/{chunk-5RAWNUVD.js → chunk-IBUTNPTQ.js} +2 -2
- package/libs/chunk-IWP4VJEP.cjs +18 -0
- package/libs/chunk-IWP4VJEP.cjs.map +1 -0
- package/libs/{chunk-ZFJ4U45S.js → chunk-KDMX3FAW.js} +2 -2
- package/libs/{chunk-DYFAUAB7.cjs → chunk-LXODKKA3.cjs} +4 -4
- package/libs/chunk-M7JLT62Q.js +9 -0
- package/libs/chunk-M7JLT62Q.js.map +1 -0
- package/libs/{chunk-IQ76HGVP.js → chunk-MBWI67UT.js} +2 -2
- package/libs/{chunk-O5XAJ7BY.cjs → chunk-NCGVF2QS.cjs} +4 -4
- package/libs/{chunk-W2UIN7EV.cjs → chunk-NPWHQVYB.cjs} +3 -3
- package/libs/{chunk-G55UJ53G.cjs → chunk-NZVSXRTB.cjs} +3 -3
- package/libs/chunk-NZVSXRTB.cjs.map +1 -0
- package/libs/{chunk-43TK2ICH.js → chunk-PMWL5XZ4.js} +3 -3
- package/libs/{chunk-KVKQLRJG.js → chunk-TF3GQKOY.js} +2 -2
- package/libs/chunk-TNEJXNZA.cjs +22 -0
- package/libs/chunk-TNEJXNZA.cjs.map +1 -0
- package/libs/{chunk-IEB64SWY.js → chunk-U5VA34SU.js} +2 -2
- package/libs/chunk-UGMP72J2.js +8 -0
- package/libs/chunk-UGMP72J2.js.map +1 -0
- package/libs/{chunk-MGPWZRBX.cjs → chunk-URBGDUFN.cjs} +6 -6
- package/libs/{chunk-QKHPHMG2.js → chunk-ZF6Y7W57.js} +5 -5
- package/libs/component-props-50e69975.d.ts +66 -0
- package/libs/components/box/box.css +1 -0
- package/libs/components/box/box.css.map +1 -0
- package/libs/components/box/box.min.css +3 -0
- package/libs/components/breadcrumbs/breadcrumb.cjs +6 -6
- package/libs/components/breadcrumbs/breadcrumb.js +3 -3
- package/libs/components/button.cjs +4 -4
- package/libs/components/button.d.cts +10 -3
- package/libs/components/button.d.ts +10 -3
- package/libs/components/button.js +2 -2
- package/libs/components/card.cjs +7 -7
- package/libs/components/card.d.cts +13 -85
- package/libs/components/card.d.ts +13 -85
- package/libs/components/card.js +2 -2
- package/libs/components/cards/card.css +1 -1
- package/libs/components/cards/card.css.map +1 -1
- package/libs/components/cards/card.min.css +2 -2
- package/libs/components/cluster/cluster.css +1 -0
- package/libs/components/cluster/cluster.css.map +1 -0
- package/libs/components/cluster/cluster.min.css +3 -0
- package/libs/components/dialog/dialog.cjs +7 -7
- package/libs/components/dialog/dialog.js +5 -5
- package/libs/components/form/fields.cjs +4 -4
- package/libs/components/form/fields.js +2 -2
- package/libs/components/form/textarea.cjs +4 -4
- package/libs/components/form/textarea.js +2 -2
- package/libs/components/grid/grid.css +1 -0
- package/libs/components/grid/grid.css.map +1 -0
- package/libs/components/grid/grid.min.css +3 -0
- package/libs/components/heading/heading.cjs +3 -3
- package/libs/components/heading/heading.js +2 -2
- package/libs/components/icons/icon.cjs +4 -4
- package/libs/components/icons/icon.d.cts +2 -2
- package/libs/components/icons/icon.d.ts +2 -2
- package/libs/components/icons/icon.js +2 -2
- package/libs/components/link/link.cjs +6 -6
- package/libs/components/link/link.js +2 -2
- package/libs/components/list/list.cjs +5 -5
- package/libs/components/list/list.js +2 -2
- package/libs/components/modal.cjs +4 -4
- package/libs/components/modal.d.cts +1 -1
- package/libs/components/modal.d.ts +1 -1
- package/libs/components/modal.js +3 -3
- package/libs/components/nav/nav.cjs +7 -7
- package/libs/components/nav/nav.js +3 -3
- package/libs/components/popover/popover.cjs +4 -4
- package/libs/components/popover/popover.d.cts +1 -1
- package/libs/components/popover/popover.d.ts +1 -1
- package/libs/components/popover/popover.js +1 -1
- package/libs/components/stack/stack.css +1 -0
- package/libs/components/stack/stack.css.map +1 -0
- package/libs/components/stack/stack.min.css +3 -0
- package/libs/components/tables/table.cjs +4 -4
- package/libs/components/tables/table.d.cts +2 -2
- package/libs/components/tables/table.d.ts +2 -2
- package/libs/components/tables/table.js +1 -1
- package/libs/components/text/text.cjs +5 -5
- package/libs/components/text/text.js +2 -2
- package/libs/hooks.cjs +4 -4
- package/libs/hooks.js +3 -3
- package/libs/{icons-287fce3a.d.ts → icons-df8e744f.d.ts} +1 -1
- package/libs/icons.cjs +3 -3
- package/libs/icons.d.cts +2 -2
- package/libs/icons.d.ts +2 -2
- package/libs/icons.js +2 -2
- package/libs/index.cjs +74 -73
- package/libs/index.cjs.map +1 -1
- package/libs/index.css +1 -1
- package/libs/index.css.map +1 -1
- package/libs/index.d.cts +925 -6
- package/libs/index.d.ts +925 -6
- package/libs/index.js +30 -30
- package/libs/index.js.map +1 -1
- package/package.json +2 -2
- package/src/App.tsx +1 -3
- package/src/components/alert/STYLES.mdx +790 -0
- package/src/components/badge/STYLES.mdx +610 -0
- package/src/components/box/README.mdx +401 -0
- package/src/components/box/STYLES.mdx +360 -0
- package/src/components/box/box.scss +245 -0
- package/src/components/box/box.stories.tsx +395 -0
- package/src/components/box/box.test.tsx +425 -0
- package/src/components/box/box.tsx +170 -0
- package/src/components/box/box.types.ts +166 -0
- package/src/components/breadcrumbs/STYLES.mdx +99 -0
- package/src/components/breadcrumbs/bc-item.tsx +0 -1
- package/src/components/buttons/STYLES.mdx +766 -0
- package/src/components/cards/STYLES.mdx +835 -0
- package/src/components/cards/card.scss +29 -21
- package/src/components/cards/card.tsx +13 -3
- package/src/components/cards/card.types.ts +13 -0
- package/src/components/cluster/README.mdx +595 -0
- package/src/components/cluster/STYLES.mdx +626 -0
- package/src/components/cluster/cluster.scss +86 -0
- package/src/components/cluster/cluster.stories.tsx +385 -0
- package/src/components/cluster/cluster.test.tsx +655 -0
- package/src/components/cluster/cluster.tsx +94 -0
- package/src/components/cluster/cluster.types.ts +75 -0
- package/src/components/details/STYLES.mdx +445 -0
- package/src/components/dialog/STYLES.mdx +888 -0
- package/src/components/flexbox/STYLES.mdx +857 -0
- package/src/components/flexbox/flex.stories.tsx +842 -141
- package/src/components/flexbox/flex.types.ts +25 -6
- package/src/components/form/STYLES.mdx +821 -0
- package/src/components/grid/README.mdx +709 -0
- package/src/components/grid/STYLES.mdx +785 -0
- package/src/components/grid/grid.scss +287 -0
- package/src/components/grid/grid.stories.tsx +486 -0
- package/src/components/grid/grid.test.tsx +981 -0
- package/src/components/grid/grid.tsx +222 -0
- package/src/components/grid/grid.types.ts +344 -0
- package/src/components/icons/STYLES.mdx +56 -0
- package/src/components/icons/components/arrow-right.tsx +0 -5
- package/src/components/images/STYLES.mdx +75 -0
- package/src/components/kit.tsx +8 -4
- package/src/components/layout/STYLES.mdx +556 -0
- package/src/components/link/STYLES.mdx +75 -0
- package/src/components/list/STYLES.mdx +631 -0
- package/src/components/nav/STYLES.mdx +460 -0
- package/src/components/popover/popover.tsx +1 -1
- package/src/components/progress/STYLES.mdx +64 -0
- package/src/components/stack/README.mdx +400 -0
- package/src/components/stack/STYLES.mdx +414 -0
- package/src/components/stack/stack.scss +109 -0
- package/src/components/stack/stack.stories.tsx +559 -0
- package/src/components/stack/stack.test.tsx +426 -0
- package/src/components/stack/stack.tsx +141 -0
- package/src/components/stack/stack.types.ts +133 -0
- package/src/components/tables/table-elements.tsx +1 -1
- package/src/components/tables/table.tsx +2 -2
- package/src/components/tag/STYLES.mdx +105 -0
- package/src/components/text-to-speech/STYLES.mdx +80 -0
- package/src/components/text-to-speech/TextToSpeech.tsx +0 -4
- package/src/components/text-to-speech/useTextToSpeech.tsx +2 -6
- package/src/components/ui.tsx +3 -3
- package/src/decorators/instructions.tsx +22 -18
- package/src/hooks/popover/popover.tsx +1 -1
- package/src/index.scss +5 -1
- package/src/index.ts +305 -12
- package/src/sass/GLOBALS-STYLES.md +631 -0
- package/src/sass/_globals.scss +45 -24
- package/src/styles/box/box.css +220 -0
- package/src/styles/box/box.css.map +1 -0
- package/src/styles/cards/card.css +22 -17
- package/src/styles/cards/card.css.map +1 -1
- package/src/styles/cluster/cluster.css +71 -0
- package/src/styles/cluster/cluster.css.map +1 -0
- package/src/styles/grid/grid.css +238 -0
- package/src/styles/grid/grid.css.map +1 -0
- package/src/styles/index.css +667 -49
- package/src/styles/index.css.map +1 -1
- package/src/styles/stack/stack.css +86 -0
- package/src/styles/stack/stack.css.map +1 -0
- package/src/types/component-props.ts +42 -13
- package/src/types/layout-primitives.ts +48 -0
- package/src/types/shared.ts +10 -26
- package/libs/chunk-23ANBDCR.js.map +0 -1
- package/libs/chunk-5QD3DWFI.js +0 -9
- package/libs/chunk-5QD3DWFI.js.map +0 -1
- package/libs/chunk-6WTC4JXH.cjs +0 -31
- package/libs/chunk-6WTC4JXH.cjs.map +0 -1
- package/libs/chunk-ENTCUJ3A.cjs +0 -13
- package/libs/chunk-ENTCUJ3A.cjs.map +0 -1
- package/libs/chunk-G55UJ53G.cjs.map +0 -1
- package/libs/chunk-HHLNOC5T.js +0 -7
- package/libs/chunk-HHLNOC5T.js.map +0 -1
- package/libs/chunk-KK47SYZI.js +0 -8
- package/libs/chunk-KK47SYZI.js.map +0 -1
- package/libs/chunk-US2I5GI7.cjs +0 -22
- package/libs/chunk-US2I5GI7.cjs.map +0 -1
- package/libs/chunk-W5TKWBFC.cjs +0 -18
- package/libs/chunk-W5TKWBFC.cjs.map +0 -1
- package/libs/chunk-Y2PFDELK.js +0 -8
- package/libs/chunk-Y2PFDELK.js.map +0 -1
- package/libs/component-props-67d978a2.d.ts +0 -38
- /package/libs/{chunk-2NRIP6RB.cjs.map → chunk-2C3YLBWP.cjs.map} +0 -0
- /package/libs/{chunk-NWJDAHP6.cjs.map → chunk-2GJHKWEK.cjs.map} +0 -0
- /package/libs/{chunk-FVROL3V5.js.map → chunk-2JCDEC32.js.map} +0 -0
- /package/libs/{chunk-IRLFZ3OL.js.map → chunk-3XJC4XUG.js.map} +0 -0
- /package/libs/{chunk-E4OSROCA.cjs.map → chunk-5QSNJQVH.cjs.map} +0 -0
- /package/libs/{chunk-O3JIHC5M.cjs.map → chunk-6BUJZ4DJ.cjs.map} +0 -0
- /package/libs/{chunk-WXBFBWYF.cjs.map → chunk-AFINOD2L.cjs.map} +0 -0
- /package/libs/{chunk-HRRHPLER.js.map → chunk-AWZLSWDO.js.map} +0 -0
- /package/libs/{chunk-CWRNJA4P.js.map → chunk-DIJBIOFE.js.map} +0 -0
- /package/libs/{chunk-GUJSMQ3V.cjs.map → chunk-EKJYOCLY.cjs.map} +0 -0
- /package/libs/{chunk-X5RKCLDC.cjs.map → chunk-F64GE6RG.cjs.map} +0 -0
- /package/libs/{chunk-5RAWNUVD.js.map → chunk-IBUTNPTQ.js.map} +0 -0
- /package/libs/{chunk-ZFJ4U45S.js.map → chunk-KDMX3FAW.js.map} +0 -0
- /package/libs/{chunk-DYFAUAB7.cjs.map → chunk-LXODKKA3.cjs.map} +0 -0
- /package/libs/{chunk-IQ76HGVP.js.map → chunk-MBWI67UT.js.map} +0 -0
- /package/libs/{chunk-O5XAJ7BY.cjs.map → chunk-NCGVF2QS.cjs.map} +0 -0
- /package/libs/{chunk-W2UIN7EV.cjs.map → chunk-NPWHQVYB.cjs.map} +0 -0
- /package/libs/{chunk-43TK2ICH.js.map → chunk-PMWL5XZ4.js.map} +0 -0
- /package/libs/{chunk-KVKQLRJG.js.map → chunk-TF3GQKOY.js.map} +0 -0
- /package/libs/{chunk-IEB64SWY.js.map → chunk-U5VA34SU.js.map} +0 -0
- /package/libs/{chunk-MGPWZRBX.cjs.map → chunk-URBGDUFN.cjs.map} +0 -0
- /package/libs/{chunk-QKHPHMG2.js.map → chunk-ZF6Y7W57.js.map} +0 -0
|
@@ -0,0 +1,790 @@
|
|
|
1
|
+
import { Meta } from "@storybook/addon-docs/blocks";
|
|
2
|
+
|
|
3
|
+
<Meta title="FP.REACT Components/Alert/Styles" />
|
|
4
|
+
|
|
5
|
+
# Alert Styles
|
|
6
|
+
|
|
7
|
+
Notification alert styling system with CSS custom properties for creating
|
|
8
|
+
accessible, semantic alerts with multiple variants and animation support.
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
The fpkit alert styling system provides accessible notification components using
|
|
13
|
+
the semantic `role="alert"` attribute. Alerts support four severity types
|
|
14
|
+
(success, error, warning, info) and three visual variants (outlined, filled,
|
|
15
|
+
soft) with built-in animations and WCAG compliance.
|
|
16
|
+
|
|
17
|
+
### Key Features
|
|
18
|
+
|
|
19
|
+
- **Semantic types** - Success, error, warning, and info alerts with color-coded
|
|
20
|
+
styling
|
|
21
|
+
- **Visual variants** - Outlined (default), filled, and soft styles
|
|
22
|
+
- **Icon support** - Dedicated icon area with proper alignment
|
|
23
|
+
- **Title and message** - Structured content with title and body sections
|
|
24
|
+
- **Animations** - Smooth entrance/exit transitions with reduced motion support
|
|
25
|
+
- **Dismissible** - Support for close buttons
|
|
26
|
+
- **CSS custom properties** - Extensive theming via CSS variables
|
|
27
|
+
- **Rem-based sizing** - All measurements use rem units (1rem = 16px)
|
|
28
|
+
- **WCAG compliant** - Proper ARIA roles, focus indicators, and color contrast
|
|
29
|
+
- **Reduced motion** - Respects user's motion preferences
|
|
30
|
+
|
|
31
|
+
## CSS Custom Properties
|
|
32
|
+
|
|
33
|
+
### Color Properties by Type
|
|
34
|
+
|
|
35
|
+
Each alert type has dedicated color variables:
|
|
36
|
+
|
|
37
|
+
```css
|
|
38
|
+
[role="alert"] {
|
|
39
|
+
/* Success colors */
|
|
40
|
+
--alert-success-bg: #e6f4ea; /* Light green background */
|
|
41
|
+
--alert-success-border: #34a853; /* Green border */
|
|
42
|
+
--alert-success-text: #1e4620; /* Dark green text */
|
|
43
|
+
|
|
44
|
+
/* Error colors */
|
|
45
|
+
--alert-error-bg: #fdeded; /* Light red background */
|
|
46
|
+
--alert-error-border: #d32f2f; /* Red border */
|
|
47
|
+
--alert-error-text: #5f2120; /* Dark red text */
|
|
48
|
+
|
|
49
|
+
/* Warning colors */
|
|
50
|
+
--alert-warning-bg: #fff4e5; /* Light orange background */
|
|
51
|
+
--alert-warning-border: #ff9800; /* Orange border */
|
|
52
|
+
--alert-warning-text: #663c00; /* Dark orange text */
|
|
53
|
+
|
|
54
|
+
/* Info colors */
|
|
55
|
+
--alert-info-bg: #e5f6fd; /* Light blue background */
|
|
56
|
+
--alert-info-border: #0288d1; /* Blue border */
|
|
57
|
+
--alert-info-text: #084154; /* Dark blue text */
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Base Alert Properties
|
|
62
|
+
|
|
63
|
+
```css
|
|
64
|
+
[role="alert"] {
|
|
65
|
+
/* Colors (customizable per instance) */
|
|
66
|
+
--alert-bg: whitesmoke; /* Background color */
|
|
67
|
+
--alert-color: currentColor; /* Text color */
|
|
68
|
+
|
|
69
|
+
/* Borders */
|
|
70
|
+
--alert-border: thin solid currentColor; /* Border style */
|
|
71
|
+
--alert-radius: var(--border-radius); /* Border radius */
|
|
72
|
+
|
|
73
|
+
/* Spacing */
|
|
74
|
+
--alert-padding: var(--spc-4); /* Internal padding */
|
|
75
|
+
--alert-gap: var(--spc-4); /* Gap between icon and message */
|
|
76
|
+
--alert-margin-block-end: 0; /* Bottom margin */
|
|
77
|
+
|
|
78
|
+
/* Animation */
|
|
79
|
+
--alert-transition-duration: 0.3s; /* Transition duration */
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Title Properties
|
|
84
|
+
|
|
85
|
+
```css
|
|
86
|
+
.alert-title {
|
|
87
|
+
--alert-title-fw: 600; /* Title font weight */
|
|
88
|
+
--alert-title-fs: inherit; /* Title font size (inherits from alert) */
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Customizing Alert Styles
|
|
93
|
+
|
|
94
|
+
Override CSS variables:
|
|
95
|
+
|
|
96
|
+
```css
|
|
97
|
+
[role="alert"] {
|
|
98
|
+
--alert-padding: 1.5rem;
|
|
99
|
+
--alert-gap: 1rem;
|
|
100
|
+
--alert-radius: 0.5rem;
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Or inline:
|
|
105
|
+
|
|
106
|
+
```html
|
|
107
|
+
<div role="alert" style="--alert-padding: 1.5rem; --alert-gap: 1rem">
|
|
108
|
+
Alert content
|
|
109
|
+
</div>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Alert Structure
|
|
113
|
+
|
|
114
|
+
### Basic Alert
|
|
115
|
+
|
|
116
|
+
Simple alert with message:
|
|
117
|
+
|
|
118
|
+
```html
|
|
119
|
+
<div role="alert" data-alert="info">
|
|
120
|
+
<p>This is an informational alert.</p>
|
|
121
|
+
</div>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**CSS Applied:**
|
|
125
|
+
|
|
126
|
+
```css
|
|
127
|
+
[role="alert"] {
|
|
128
|
+
background-color: whitesmoke;
|
|
129
|
+
border: thin solid currentColor;
|
|
130
|
+
color: currentColor;
|
|
131
|
+
padding: var(--spc-4);
|
|
132
|
+
font-size: var(--fs-0);
|
|
133
|
+
line-height: 1.6;
|
|
134
|
+
display: flex;
|
|
135
|
+
flex-direction: row;
|
|
136
|
+
border-radius: var(--border-radius);
|
|
137
|
+
gap: var(--spc-4);
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Alert with Title
|
|
142
|
+
|
|
143
|
+
Alert with title and message:
|
|
144
|
+
|
|
145
|
+
```html
|
|
146
|
+
<div role="alert" data-alert="success">
|
|
147
|
+
<div class="alert-message">
|
|
148
|
+
<strong class="alert-title">Success!</strong>
|
|
149
|
+
<p>Your changes have been saved successfully.</p>
|
|
150
|
+
</div>
|
|
151
|
+
</div>
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
**CSS for Title:**
|
|
155
|
+
|
|
156
|
+
```css
|
|
157
|
+
.alert-title {
|
|
158
|
+
margin-block-end: 0.25rem;
|
|
159
|
+
margin-block-start: 0;
|
|
160
|
+
font-weight: 600;
|
|
161
|
+
font-size: inherit;
|
|
162
|
+
line-height: 1.4;
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Alert with Icon
|
|
167
|
+
|
|
168
|
+
Alert with icon and message:
|
|
169
|
+
|
|
170
|
+
```html
|
|
171
|
+
<div role="alert" data-alert="warning">
|
|
172
|
+
<span class="alert-icon" aria-hidden="true">⚠️</span>
|
|
173
|
+
<div class="alert-message">
|
|
174
|
+
<strong class="alert-title">Warning</strong>
|
|
175
|
+
<p>Please review your input before proceeding.</p>
|
|
176
|
+
</div>
|
|
177
|
+
</div>
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**CSS for Icon:**
|
|
181
|
+
|
|
182
|
+
```css
|
|
183
|
+
.alert-icon {
|
|
184
|
+
margin-block-start: 0;
|
|
185
|
+
align-items: center;
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Alert with Close Button
|
|
190
|
+
|
|
191
|
+
Dismissible alert:
|
|
192
|
+
|
|
193
|
+
```html
|
|
194
|
+
<div role="alert" data-alert="info" data-visible="true">
|
|
195
|
+
<div class="alert-message">
|
|
196
|
+
<p>This alert can be dismissed.</p>
|
|
197
|
+
</div>
|
|
198
|
+
<button
|
|
199
|
+
type="button"
|
|
200
|
+
data-btn="icon"
|
|
201
|
+
aria-label="Close alert"
|
|
202
|
+
onclick="this.parentElement.setAttribute('data-visible', 'false')"
|
|
203
|
+
>
|
|
204
|
+
✕
|
|
205
|
+
</button>
|
|
206
|
+
</div>
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
**Note:** The `data-visible="false"` triggers exit animation via opacity and
|
|
210
|
+
transform.
|
|
211
|
+
|
|
212
|
+
## Alert Types
|
|
213
|
+
|
|
214
|
+
Control alert type using the `data-alert` attribute:
|
|
215
|
+
|
|
216
|
+
| Data Attribute | Type | Description |
|
|
217
|
+
| ---------------------- | ------- | ----------------------------- |
|
|
218
|
+
| `data-alert="success"` | Success | Positive feedback (green) |
|
|
219
|
+
| `data-alert="error"` | Error | Error messages (red) |
|
|
220
|
+
| `data-alert="warning"` | Warning | Warnings/cautions (orange) |
|
|
221
|
+
| `data-alert="info"` | Info | Informational messages (blue) |
|
|
222
|
+
|
|
223
|
+
### Success Alert
|
|
224
|
+
|
|
225
|
+
```html
|
|
226
|
+
<div role="alert" data-alert="success">
|
|
227
|
+
<span class="alert-icon" aria-hidden="true">✓</span>
|
|
228
|
+
<div class="alert-message">
|
|
229
|
+
<strong class="alert-title">Success</strong>
|
|
230
|
+
<p>Operation completed successfully.</p>
|
|
231
|
+
</div>
|
|
232
|
+
</div>
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
**CSS:**
|
|
236
|
+
|
|
237
|
+
```css
|
|
238
|
+
[data-alert~="success"] {
|
|
239
|
+
--alert-bg: #e6f4ea;
|
|
240
|
+
--alert-color: #1e4620;
|
|
241
|
+
border-color: #34a853;
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Error Alert
|
|
246
|
+
|
|
247
|
+
```html
|
|
248
|
+
<div role="alert" data-alert="error">
|
|
249
|
+
<span class="alert-icon" aria-hidden="true">✕</span>
|
|
250
|
+
<div class="alert-message">
|
|
251
|
+
<strong class="alert-title">Error</strong>
|
|
252
|
+
<p>Something went wrong. Please try again.</p>
|
|
253
|
+
</div>
|
|
254
|
+
</div>
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
**CSS:**
|
|
258
|
+
|
|
259
|
+
```css
|
|
260
|
+
[data-alert~="error"] {
|
|
261
|
+
--alert-bg: #fdeded;
|
|
262
|
+
--alert-color: #5f2120;
|
|
263
|
+
border-color: #d32f2f;
|
|
264
|
+
}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Warning Alert
|
|
268
|
+
|
|
269
|
+
```html
|
|
270
|
+
<div role="alert" data-alert="warning">
|
|
271
|
+
<span class="alert-icon" aria-hidden="true">⚠️</span>
|
|
272
|
+
<div class="alert-message">
|
|
273
|
+
<strong class="alert-title">Warning</strong>
|
|
274
|
+
<p>This action cannot be undone.</p>
|
|
275
|
+
</div>
|
|
276
|
+
</div>
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
**CSS:**
|
|
280
|
+
|
|
281
|
+
```css
|
|
282
|
+
[data-alert~="warning"] {
|
|
283
|
+
--alert-bg: #fff4e5;
|
|
284
|
+
--alert-color: #663c00;
|
|
285
|
+
border-color: #ff9800;
|
|
286
|
+
}
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### Info Alert
|
|
290
|
+
|
|
291
|
+
```html
|
|
292
|
+
<div role="alert" data-alert="info">
|
|
293
|
+
<span class="alert-icon" aria-hidden="true">ℹ️</span>
|
|
294
|
+
<div class="alert-message">
|
|
295
|
+
<strong class="alert-title">Information</strong>
|
|
296
|
+
<p>Here's some helpful information.</p>
|
|
297
|
+
</div>
|
|
298
|
+
</div>
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
**CSS:**
|
|
302
|
+
|
|
303
|
+
```css
|
|
304
|
+
[data-alert~="info"] {
|
|
305
|
+
--alert-bg: #e5f6fd;
|
|
306
|
+
--alert-color: #084154;
|
|
307
|
+
border-color: #0288d1;
|
|
308
|
+
}
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
## Visual Variants
|
|
312
|
+
|
|
313
|
+
Control visual style using the `data-variant` attribute:
|
|
314
|
+
|
|
315
|
+
| Data Attribute | Variant | Description |
|
|
316
|
+
| ------------------------ | -------- | ---------------------------------------------- |
|
|
317
|
+
| _(none)_ or `"outlined"` | Outlined | Light background with colored border (default) |
|
|
318
|
+
| `data-variant="filled"` | Filled | Solid colored background with white text |
|
|
319
|
+
| `data-variant="soft"` | Soft | Light background without border |
|
|
320
|
+
|
|
321
|
+
### Outlined Variant (Default)
|
|
322
|
+
|
|
323
|
+
Light background with colored border:
|
|
324
|
+
|
|
325
|
+
```html
|
|
326
|
+
<div role="alert" data-alert="info" data-variant="outlined">
|
|
327
|
+
<p>Outlined alert (default style).</p>
|
|
328
|
+
</div>
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### Filled Variant
|
|
332
|
+
|
|
333
|
+
Solid background with white text:
|
|
334
|
+
|
|
335
|
+
```html
|
|
336
|
+
<div role="alert" data-alert="success" data-variant="filled">
|
|
337
|
+
<span class="alert-icon" aria-hidden="true">✓</span>
|
|
338
|
+
<div class="alert-message">
|
|
339
|
+
<strong class="alert-title">Success</strong>
|
|
340
|
+
<p>Changes saved successfully.</p>
|
|
341
|
+
</div>
|
|
342
|
+
</div>
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
**CSS:**
|
|
346
|
+
|
|
347
|
+
```css
|
|
348
|
+
[data-variant="filled"][data-alert~="success"] {
|
|
349
|
+
--alert-bg: #34a853; /* Solid green */
|
|
350
|
+
--alert-color: white;
|
|
351
|
+
border: none;
|
|
352
|
+
}
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
### Soft Variant
|
|
356
|
+
|
|
357
|
+
Light background without border:
|
|
358
|
+
|
|
359
|
+
```html
|
|
360
|
+
<div role="alert" data-alert="warning" data-variant="soft">
|
|
361
|
+
<span class="alert-icon" aria-hidden="true">⚠️</span>
|
|
362
|
+
<div class="alert-message">
|
|
363
|
+
<p>Soft warning alert without border.</p>
|
|
364
|
+
</div>
|
|
365
|
+
</div>
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
**CSS:**
|
|
369
|
+
|
|
370
|
+
```css
|
|
371
|
+
[data-variant="soft"] {
|
|
372
|
+
border: none;
|
|
373
|
+
}
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
## Animations
|
|
377
|
+
|
|
378
|
+
### Entrance/Exit Animation
|
|
379
|
+
|
|
380
|
+
Alerts automatically animate in and out:
|
|
381
|
+
|
|
382
|
+
```css
|
|
383
|
+
[role="alert"] {
|
|
384
|
+
transition:
|
|
385
|
+
opacity 0.3s ease,
|
|
386
|
+
transform 0.3s ease;
|
|
387
|
+
opacity: 1;
|
|
388
|
+
transform: translateY(0);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/* Hidden state */
|
|
392
|
+
[role="alert"]:not([data-visible="true"]) {
|
|
393
|
+
opacity: 0;
|
|
394
|
+
transform: translateY(-0.5rem); /* Slides up */
|
|
395
|
+
}
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
### Reduced Motion Support
|
|
399
|
+
|
|
400
|
+
Respects user's motion preferences:
|
|
401
|
+
|
|
402
|
+
```css
|
|
403
|
+
@media (prefers-reduced-motion: reduce) {
|
|
404
|
+
[role="alert"] {
|
|
405
|
+
transition-duration: 0.01ms; /* Near-instant */
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
## Real-World Examples
|
|
411
|
+
|
|
412
|
+
### Form Validation Alert
|
|
413
|
+
|
|
414
|
+
```html
|
|
415
|
+
<div role="alert" data-alert="error" data-visible="true">
|
|
416
|
+
<span class="alert-icon" aria-hidden="true">✕</span>
|
|
417
|
+
<div class="alert-message">
|
|
418
|
+
<strong class="alert-title">Validation Error</strong>
|
|
419
|
+
<p>Please correct the following errors:</p>
|
|
420
|
+
<ul>
|
|
421
|
+
<li>Email address is required</li>
|
|
422
|
+
<li>Password must be at least 8 characters</li>
|
|
423
|
+
</ul>
|
|
424
|
+
</div>
|
|
425
|
+
</div>
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
### Success Notification
|
|
429
|
+
|
|
430
|
+
```html
|
|
431
|
+
<div
|
|
432
|
+
role="alert"
|
|
433
|
+
data-alert="success"
|
|
434
|
+
data-variant="filled"
|
|
435
|
+
data-visible="true"
|
|
436
|
+
>
|
|
437
|
+
<span class="alert-icon" aria-hidden="true">✓</span>
|
|
438
|
+
<div class="alert-message">
|
|
439
|
+
<strong class="alert-title">Account Created</strong>
|
|
440
|
+
<p>Welcome! Your account has been created successfully.</p>
|
|
441
|
+
</div>
|
|
442
|
+
<button type="button" data-btn="icon" aria-label="Close" style="color: white">
|
|
443
|
+
✕
|
|
444
|
+
</button>
|
|
445
|
+
</div>
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
### Warning with Action
|
|
449
|
+
|
|
450
|
+
```html
|
|
451
|
+
<div role="alert" data-alert="warning">
|
|
452
|
+
<span class="alert-icon" aria-hidden="true">⚠️</span>
|
|
453
|
+
<div class="alert-message">
|
|
454
|
+
<strong class="alert-title">Session Expiring</strong>
|
|
455
|
+
<p>Your session will expire in 5 minutes.</p>
|
|
456
|
+
<button type="button" onclick="extendSession()">Extend Session</button>
|
|
457
|
+
</div>
|
|
458
|
+
</div>
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
### Info Banner
|
|
462
|
+
|
|
463
|
+
```html
|
|
464
|
+
<div role="alert" data-alert="info" data-variant="soft">
|
|
465
|
+
<span class="alert-icon" aria-hidden="true">ℹ️</span>
|
|
466
|
+
<div class="alert-message">
|
|
467
|
+
<p>
|
|
468
|
+
<strong>New feature available!</strong> Check out our updated dashboard.
|
|
469
|
+
<a href="/dashboard">Learn more</a>
|
|
470
|
+
</p>
|
|
471
|
+
</div>
|
|
472
|
+
</div>
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
### Stack of Alerts
|
|
476
|
+
|
|
477
|
+
```html
|
|
478
|
+
<div style="display: flex; flex-direction: column; gap: 1rem">
|
|
479
|
+
<div role="alert" data-alert="success" data-visible="true">
|
|
480
|
+
<p>Item added to cart.</p>
|
|
481
|
+
</div>
|
|
482
|
+
<div role="alert" data-alert="info" data-visible="true">
|
|
483
|
+
<p>Free shipping on orders over $50.</p>
|
|
484
|
+
</div>
|
|
485
|
+
</div>
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
### Alert with Custom Colors
|
|
489
|
+
|
|
490
|
+
```html
|
|
491
|
+
<div
|
|
492
|
+
role="alert"
|
|
493
|
+
style="--alert-bg: #f3e5f5; --alert-color: #4a148c; border-color: #9c27b0"
|
|
494
|
+
>
|
|
495
|
+
<span class="alert-icon" aria-hidden="true">🎉</span>
|
|
496
|
+
<div class="alert-message">
|
|
497
|
+
<strong class="alert-title">Congratulations!</strong>
|
|
498
|
+
<p>You've earned a new badge.</p>
|
|
499
|
+
</div>
|
|
500
|
+
</div>
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
### Alert with Heading Element
|
|
504
|
+
|
|
505
|
+
```html
|
|
506
|
+
<div role="alert" data-alert="error">
|
|
507
|
+
<span class="alert-icon" aria-hidden="true">✕</span>
|
|
508
|
+
<div class="alert-message">
|
|
509
|
+
<h3 class="alert-title">Payment Failed</h3>
|
|
510
|
+
<p>
|
|
511
|
+
Your payment could not be processed. Please check your payment details and
|
|
512
|
+
try again.
|
|
513
|
+
</p>
|
|
514
|
+
</div>
|
|
515
|
+
</div>
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
**Note:** Heading elements (h2-h6) can be used with `.alert-title` class and
|
|
519
|
+
will have their default margins/sizes reset.
|
|
520
|
+
|
|
521
|
+
## Accessibility Considerations
|
|
522
|
+
|
|
523
|
+
### ARIA Role
|
|
524
|
+
|
|
525
|
+
Always use `role="alert"`:
|
|
526
|
+
|
|
527
|
+
```html
|
|
528
|
+
<div role="alert" data-alert="error">
|
|
529
|
+
<p>Error message</p>
|
|
530
|
+
</div>
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
**Why:** The `role="alert"` attribute announces the alert to screen readers
|
|
534
|
+
immediately when it appears.
|
|
535
|
+
|
|
536
|
+
### Screen Reader Only Text
|
|
537
|
+
|
|
538
|
+
Use `.sr-only` for additional context:
|
|
539
|
+
|
|
540
|
+
```html
|
|
541
|
+
<div role="alert" data-alert="success">
|
|
542
|
+
<span class="sr-only">Success:</span>
|
|
543
|
+
<p>Changes saved.</p>
|
|
544
|
+
</div>
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
**CSS for `.sr-only`:**
|
|
548
|
+
|
|
549
|
+
```css
|
|
550
|
+
.sr-only {
|
|
551
|
+
position: absolute;
|
|
552
|
+
width: 1px;
|
|
553
|
+
height: 1px;
|
|
554
|
+
padding: 0;
|
|
555
|
+
margin: -1px;
|
|
556
|
+
overflow: hidden;
|
|
557
|
+
clip: rect(0, 0, 0, 0);
|
|
558
|
+
white-space: nowrap;
|
|
559
|
+
border-width: 0;
|
|
560
|
+
}
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
### Icon Accessibility
|
|
564
|
+
|
|
565
|
+
Always add `aria-hidden="true"` to decorative icons:
|
|
566
|
+
|
|
567
|
+
```html
|
|
568
|
+
<span class="alert-icon" aria-hidden="true">✓</span>
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
**Why:** Decorative icons shouldn't be announced to screen readers. The alert
|
|
572
|
+
type (success, error, etc.) provides sufficient context.
|
|
573
|
+
|
|
574
|
+
### Close Button Accessibility
|
|
575
|
+
|
|
576
|
+
Provide accessible labels:
|
|
577
|
+
|
|
578
|
+
```html
|
|
579
|
+
<button type="button" data-btn="icon" aria-label="Close alert">✕</button>
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
### Focus Management
|
|
583
|
+
|
|
584
|
+
Alerts with interactive elements (buttons, links) should be keyboard-accessible:
|
|
585
|
+
|
|
586
|
+
```css
|
|
587
|
+
[role="alert"]:focus {
|
|
588
|
+
outline: 2px solid currentColor;
|
|
589
|
+
outline-offset: 2px;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
/* Hide outline for mouse clicks */
|
|
593
|
+
[role="alert"]:focus:not(:focus-visible) {
|
|
594
|
+
outline: none;
|
|
595
|
+
}
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
### Color Contrast
|
|
599
|
+
|
|
600
|
+
Alert colors meet WCAG AA contrast requirements:
|
|
601
|
+
|
|
602
|
+
| Type | Background | Text Color | Contrast Ratio |
|
|
603
|
+
| ------- | ---------- | ---------- | -------------- |
|
|
604
|
+
| Success | #e6f4ea | #1e4620 | 10.2:1 ✓ |
|
|
605
|
+
| Error | #fdeded | #5f2120 | 8.5:1 ✓ |
|
|
606
|
+
| Warning | #fff4e5 | #663c00 | 9.1:1 ✓ |
|
|
607
|
+
| Info | #e5f6fd | #084154 | 11.4:1 ✓ |
|
|
608
|
+
|
|
609
|
+
**Filled Variant:** White text on colored backgrounds also meets contrast
|
|
610
|
+
requirements.
|
|
611
|
+
|
|
612
|
+
## Dismissible Alerts
|
|
613
|
+
|
|
614
|
+
### JavaScript for Dismissal
|
|
615
|
+
|
|
616
|
+
```html
|
|
617
|
+
<div role="alert" data-alert="info" data-visible="true" id="myAlert">
|
|
618
|
+
<div class="alert-message">
|
|
619
|
+
<p>Dismissible alert.</p>
|
|
620
|
+
</div>
|
|
621
|
+
<button
|
|
622
|
+
type="button"
|
|
623
|
+
data-btn="icon"
|
|
624
|
+
aria-label="Close"
|
|
625
|
+
onclick="dismissAlert('myAlert')"
|
|
626
|
+
>
|
|
627
|
+
✕
|
|
628
|
+
</button>
|
|
629
|
+
</div>
|
|
630
|
+
|
|
631
|
+
<script>
|
|
632
|
+
function dismissAlert(id) {
|
|
633
|
+
const alert = document.getElementById(id);
|
|
634
|
+
alert.setAttribute("data-visible", "false");
|
|
635
|
+
|
|
636
|
+
// Remove from DOM after animation completes
|
|
637
|
+
setTimeout(() => {
|
|
638
|
+
alert.remove();
|
|
639
|
+
}, 300); // Match --alert-transition-duration
|
|
640
|
+
}
|
|
641
|
+
</script>
|
|
642
|
+
```
|
|
643
|
+
|
|
644
|
+
### Auto-Dismiss
|
|
645
|
+
|
|
646
|
+
```html
|
|
647
|
+
<div role="alert" data-alert="success" data-visible="true" id="autoAlert">
|
|
648
|
+
<p>This alert will auto-dismiss in 5 seconds.</p>
|
|
649
|
+
</div>
|
|
650
|
+
|
|
651
|
+
<script>
|
|
652
|
+
setTimeout(() => {
|
|
653
|
+
dismissAlert("autoAlert");
|
|
654
|
+
}, 5000);
|
|
655
|
+
</script>
|
|
656
|
+
```
|
|
657
|
+
|
|
658
|
+
## CSS Variable Naming Convention
|
|
659
|
+
|
|
660
|
+
All alert CSS variables follow specific patterns:
|
|
661
|
+
|
|
662
|
+
### Property Mapping
|
|
663
|
+
|
|
664
|
+
| Category | Variable Pattern | Example |
|
|
665
|
+
| --------------- | ------------------------------- | ------------------------------------------ |
|
|
666
|
+
| **Type Colors** | `--alert-{type}-{property}` | `--alert-success-bg`, `--alert-error-text` |
|
|
667
|
+
| **Base Styles** | `--alert-{property}` | `--alert-bg`, `--alert-border` |
|
|
668
|
+
| **Title** | `--alert-title-{property}` | `--alert-title-fw`, `--alert-title-fs` |
|
|
669
|
+
| **Animation** | `--alert-transition-{property}` | `--alert-transition-duration` |
|
|
670
|
+
|
|
671
|
+
### Common Variables Quick Reference
|
|
672
|
+
|
|
673
|
+
```css
|
|
674
|
+
/* Success Colors */
|
|
675
|
+
--alert-success-bg
|
|
676
|
+
--alert-success-border
|
|
677
|
+
--alert-success-text
|
|
678
|
+
|
|
679
|
+
/* Error Colors */
|
|
680
|
+
--alert-error-bg
|
|
681
|
+
--alert-error-border
|
|
682
|
+
--alert-error-text
|
|
683
|
+
|
|
684
|
+
/* Warning Colors */
|
|
685
|
+
--alert-warning-bg
|
|
686
|
+
--alert-warning-border
|
|
687
|
+
--alert-warning-text
|
|
688
|
+
|
|
689
|
+
/* Info Colors */
|
|
690
|
+
--alert-info-bg
|
|
691
|
+
--alert-info-border
|
|
692
|
+
--alert-info-text
|
|
693
|
+
|
|
694
|
+
/* Base Styling */
|
|
695
|
+
--alert-bg /* Background color */
|
|
696
|
+
--alert-color /* Text color */
|
|
697
|
+
--alert-border /* Border style */
|
|
698
|
+
--alert-radius /* Border radius */
|
|
699
|
+
--alert-padding /* Padding */
|
|
700
|
+
--alert-gap /* Gap between icon and message */
|
|
701
|
+
--alert-margin-block-end /* Bottom margin */
|
|
702
|
+
|
|
703
|
+
/* Animation */
|
|
704
|
+
--alert-transition-duration /* Transition duration */
|
|
705
|
+
|
|
706
|
+
/* Title */
|
|
707
|
+
--alert-title-fw /* Title font weight */
|
|
708
|
+
--alert-title-fs /* Title font size */
|
|
709
|
+
```
|
|
710
|
+
|
|
711
|
+
## Browser Support
|
|
712
|
+
|
|
713
|
+
The alert styles use modern CSS features:
|
|
714
|
+
|
|
715
|
+
- **CSS Custom Properties:** All modern browsers (IE11 not supported)
|
|
716
|
+
- **Flexbox:** All modern browsers
|
|
717
|
+
- **`:focus-visible`:** Chrome 86+, Firefox 85+, Safari 15.4+
|
|
718
|
+
- **`@media (prefers-reduced-motion)`:** Chrome 74+, Firefox 63+, Safari 10.1+
|
|
719
|
+
- **Logical properties** (`margin-block-start`): Chrome 87+, Firefox 66+, Safari
|
|
720
|
+
14.1+
|
|
721
|
+
- **`role="alert"`:** All browsers with screen reader support
|
|
722
|
+
|
|
723
|
+
## Performance Tips
|
|
724
|
+
|
|
725
|
+
### Minimize Animation Overhead
|
|
726
|
+
|
|
727
|
+
For static alerts, disable animations:
|
|
728
|
+
|
|
729
|
+
```html
|
|
730
|
+
<div role="alert" style="--alert-transition-duration: 0s">
|
|
731
|
+
<p>Static alert (no animation).</p>
|
|
732
|
+
</div>
|
|
733
|
+
```
|
|
734
|
+
|
|
735
|
+
### Use CSS Classes
|
|
736
|
+
|
|
737
|
+
Create reusable alert variants:
|
|
738
|
+
|
|
739
|
+
```css
|
|
740
|
+
.alert-compact {
|
|
741
|
+
--alert-padding: 0.75rem;
|
|
742
|
+
--alert-gap: 0.5rem;
|
|
743
|
+
font-size: 0.875rem;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
.alert-large {
|
|
747
|
+
--alert-padding: 1.5rem;
|
|
748
|
+
--alert-gap: 1rem;
|
|
749
|
+
font-size: 1.125rem;
|
|
750
|
+
}
|
|
751
|
+
```
|
|
752
|
+
|
|
753
|
+
```html
|
|
754
|
+
<div role="alert" data-alert="info" class="alert-compact">
|
|
755
|
+
<p>Compact alert.</p>
|
|
756
|
+
</div>
|
|
757
|
+
```
|
|
758
|
+
|
|
759
|
+
## Migration from Other Systems
|
|
760
|
+
|
|
761
|
+
### From Tailwind CSS
|
|
762
|
+
|
|
763
|
+
| Tailwind | fpkit Alert |
|
|
764
|
+
| ------------------------------------- | --------------------------------------------- |
|
|
765
|
+
| `class="alert alert-success"` | `role="alert" data-alert="success"` |
|
|
766
|
+
| `class="alert alert-error"` | `role="alert" data-alert="error"` |
|
|
767
|
+
| `class="bg-green-100 text-green-800"` | `data-alert="success"` |
|
|
768
|
+
| `class="border border-red-500"` | `data-alert="error" data-variant="outlined"` |
|
|
769
|
+
| Custom dismiss button | `<button data-btn="icon" aria-label="Close">` |
|
|
770
|
+
|
|
771
|
+
### From Bootstrap
|
|
772
|
+
|
|
773
|
+
| Bootstrap | fpkit Alert |
|
|
774
|
+
| ----------------------------- | --------------------------------------- |
|
|
775
|
+
| `class="alert alert-success"` | `role="alert" data-alert="success"` |
|
|
776
|
+
| `class="alert alert-danger"` | `role="alert" data-alert="error"` |
|
|
777
|
+
| `class="alert alert-warning"` | `role="alert" data-alert="warning"` |
|
|
778
|
+
| `class="alert alert-info"` | `role="alert" data-alert="info"` |
|
|
779
|
+
| `class="alert-dismissible"` | Add close button with `data-btn="icon"` |
|
|
780
|
+
|
|
781
|
+
## Related Resources
|
|
782
|
+
|
|
783
|
+
- **React Component** - See [README.mdx](./README.mdx) for the React Alert
|
|
784
|
+
component API
|
|
785
|
+
- **MDN: ARIA alert role** -
|
|
786
|
+
[https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/alert_role](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/alert_role)
|
|
787
|
+
- **W3C ARIA: Alert Pattern** -
|
|
788
|
+
[https://www.w3.org/WAI/ARIA/apg/patterns/alert/](https://www.w3.org/WAI/ARIA/apg/patterns/alert/)
|
|
789
|
+
- **CSS Custom Properties** -
|
|
790
|
+
[https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties)
|