You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+90Lines changed: 90 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -39,6 +39,26 @@ Start by marking an element as a container using the `@container` class, and the
39
39
40
40
By default we provide [container sizes](#configuration) from `@xs` (`20rem`) to `@7xl` (`80rem`).
41
41
42
+
In case of `max-width` container queries:
43
+
44
+
```html
45
+
<divclass="@container">
46
+
<divclass="@max-lg:underline">
47
+
<!-- This text will be underlined when the container is larger than `32rem` -->
48
+
</div>
49
+
</div>
50
+
```
51
+
52
+
or alternatively there is an `atMax` version:
53
+
54
+
```html
55
+
<divclass="@container">
56
+
<divclass="atMax-lg:underline">
57
+
<!-- This text will be underlined when the container is larger than `32rem` -->
58
+
</div>
59
+
</div>
60
+
```
61
+
42
62
### Named containers
43
63
44
64
You can optionally name containers using a `@container/{name}` class, and then include that name in the container variants using classes like `@lg/{name}:underline`:
@@ -52,6 +72,26 @@ You can optionally name containers using a `@container/{name}` class, and then i
52
72
</div>
53
73
```
54
74
75
+
In case of `max-width` container queries:
76
+
77
+
```html
78
+
<divclass="@container/main">
79
+
<divclass="@max-lg/main:underline">
80
+
<!-- This text will be underlined when the container is larger than `32rem` -->
81
+
</div>
82
+
</div>
83
+
```
84
+
85
+
or alternatively the `atMax` version:
86
+
87
+
```html
88
+
<divclass="@container/main">
89
+
<divclass="atMax-lg/main:underline">
90
+
<!-- This text will be underlined when the container is larger than `32rem` -->
91
+
</div>
92
+
</div>
93
+
```
94
+
55
95
### Arbitrary container sizes
56
96
57
97
In addition to using one of the [container sizes](#configuration) provided by default, you can also create one-off sizes using any arbitrary value:
@@ -64,6 +104,56 @@ In addition to using one of the [container sizes](#configuration) provided by de
64
104
</div>
65
105
```
66
106
107
+
In case of `max-width` container queries:
108
+
109
+
```html
110
+
<divclass="@container">
111
+
<divclass="@max-[17.5rem]:underline">
112
+
<!-- This text will be underlined when the container is larger than `32rem` -->
113
+
</div>
114
+
</div>
115
+
```
116
+
117
+
or alternatively the `atMax` version:
118
+
119
+
```html
120
+
<divclass="@container">
121
+
<divclass="atMax-[17.5rem]:underline">
122
+
<!-- This text will be underlined when the container is larger than `32rem` -->
123
+
</div>
124
+
</div>
125
+
```
126
+
127
+
### Combining named containers and arbitrary container sizes
128
+
129
+
You can combine both [named containers](#named-containers) and
130
+
[arbitrary container sizes](#arbitrary-container-sizes) this way:
131
+
132
+
```html
133
+
<divclass="@container/main">
134
+
<divclass="@[17.5rem]/main:underline"></div>
135
+
<!-- This text will be underlined when the container is larger than `17.5rem` -->
136
+
</div>
137
+
</div>
138
+
```
139
+
140
+
In case of `max-width` container queries only the `atMax` version is working
141
+
because to support extraction of `@max-[17.5rem]/main:underline` by the default
142
+
extractor of Tailwind CSS its regular expressions would need to be updated
143
+
(or a custom extractor could be used but that is really an advanced topic since it
144
+
overrides the default one which does really an excellent job to extract class name
145
+
candidates from anywhere).
146
+
147
+
```html
148
+
<divclass="@container/main">
149
+
<divclass="atMax-[17.5rem]/main:underline">
150
+
<!-- This text will be underlined when the container is larger than `32rem` -->
151
+
</div>
152
+
</div>
153
+
```
154
+
155
+
156
+
67
157
### Removing a container
68
158
69
159
To stop an element from acting as a container, use the `@container-normal` class.
0 commit comments