@@ -47,6 +47,92 @@ To add an action to a toast, use the `toast.action` property.
47
47
48
48
<Example id = " action" />
49
49
50
+ ## Styling guide
51
+
52
+ There's a minimal styling required for the toast to work correctly.
53
+
54
+ ### Toast root
55
+
56
+ The toast root will be assigned these css properties at runtime:
57
+
58
+ - ` --x ` - The x position
59
+ - ` --y ` - The y position
60
+ - ` --scale ` - The scale
61
+ - ` --z-index ` - The z-index
62
+ - ` --height ` - The height
63
+ - ` --opacity ` - The opacity
64
+ - ` --gap ` - The gap between toasts
65
+
66
+ ``` css
67
+ [data-scope = ' toast' ][data-part = ' root' ] {
68
+ translate : var (--x ) var (--y );
69
+ scale : var (--scale );
70
+ z-index : var (--z-index );
71
+ height : var (--height );
72
+ opacity : var (--opacity );
73
+ will-change : translate, opacity, scale;
74
+ transition :
75
+ translate 400ms ,
76
+ scale 400ms ,
77
+ opacity 400ms ,
78
+ height 400ms ,
79
+ box-shadow 200ms ;
80
+ transition-timing-function : cubic-bezier (0.21 , 1.02 , 0.73 , 1 );
81
+
82
+ &[data-state ='closed '] {
83
+ transition :
84
+ translate 400ms ,
85
+ scale 400ms ,
86
+ opacity 200ms ;
87
+ transition-timing-function : cubic-bezier (0.06 , 0.71 , 0.55 , 1 );
88
+ }
89
+ }
90
+ ```
91
+
92
+ ### Styling based on type
93
+
94
+ You can also style based on the ` data-type ` attribute.
95
+
96
+ ``` css
97
+ [data-scope = ' toast' ][data-part = ' root' ] {
98
+ &[data-type ='error '] {
99
+ background : red ;
100
+ color : white ;
101
+ }
102
+
103
+ &[data-type = ' info' ] {
104
+ background : blue ;
105
+ color : white ;
106
+ }
107
+
108
+ &[data-type = ' warning' ] {
109
+ background : orange ;
110
+ }
111
+
112
+ &[data-type = ' success' ] {
113
+ background : green ;
114
+ color : white ;
115
+ }
116
+ }
117
+ ```
118
+
119
+ ### Mobile considerations
120
+
121
+ A very common use case is to adjust the toast width on mobile so it spans the full width of the screen.
122
+
123
+ ``` css
124
+ @media (max-width : 640px ) {
125
+ [data-scope = ' toast' ][data-part = ' group' ] {
126
+ width : 100% ;
127
+ }
128
+
129
+ [data-scope = ' toast' ][data-part = ' root' ] {
130
+ inset-inline : 0 ;
131
+ width : calc (100% - var (--gap ) * 2 );
132
+ }
133
+ }
134
+ ```
135
+
50
136
## API Reference
51
137
52
138
<ComponentTypes id = " toast" />
0 commit comments