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
This will cause two sets of attributes get applied. Attributes representing width sizes will be the same as [usual](#concept-of-sizes). Attributes representing height sizes will be postifed with `-height`: `xxs-height`, `xl-height`, etc.
443
+
430
444
This lets you apply CSS like this:
431
445
432
-
```
433
-
.foo[width-at-m][height-from-m] {}
446
+
```css
447
+
.foo[to-s][from-xl-height] {
448
+
/* I am thin and tall */
449
+
}
434
450
```
435
451
436
-
Another use case is when you already have many styles written for default attributes, and then your designer tells you to apply a new style based on non-default breakpoints. Multiple modifiers lets you do this without rewriting existing styles:
452
+
You can customize height sizes into `@sizesHeight`. Make sure that height size names are different from width sizes!
⚠ Never apply two or more modifiers with the same prefix to the same element. The `{{element-query}}` modifier adds and removes attributes aggressively and will interfere with other modifiers/libraries manipulating same attributes.
446
477
447
478
479
+
### Customizing attribute prefix
448
480
449
-
### Using both width and height on the Element Query component
481
+
Use the `prefix` argument to adjust attribute prefix:
450
482
451
-
You can pass your height sizes into `@sizesHeight`. Make sure that height size names are different from [width sizes](#concept-of-sizes)!
This will result in attributes like `data-foo-at-xl`, `data-foo-from-m`, etc.
492
+
493
+
494
+
495
+
### Using multiple modifiers on the same element
496
+
497
+
One use case for this is to apply new styles based on new breakpoints without breaking (and refactoring) existing styles.
498
+
499
+
You can use both width and height element queries on the same element like this:
500
+
501
+
```html
502
+
<img
503
+
class="foo"
504
+
{{element-query}}
505
+
{{element-querysizes=(new-small=0new-large=700)}}
458
506
>
459
-
<to.smallWidth><from.largeHeight>
460
-
I am thin and tall.
461
-
</from.largeHeight></to.smallWidth>
462
-
</ElementQuery>
463
507
```
464
508
465
-
You can also pass `true` to `@sizesHeight`, which will enable default sizes. They are the same as [width sizes](#concept-of-sizes) but postfixed with `Height`: `xxsHeight`, `xlHeight`, etc.
509
+
or
466
510
467
511
```html
468
-
<ElementQuery@heightRules=trueas|atfromto|>
469
-
<to.s><from.lHeight>
470
-
I am thin and tall.
471
-
</from.lHeight></to.s>
472
-
</ElementQuery>
512
+
<img
513
+
class="foo"
514
+
{{element-query}}
515
+
{{element-queryprefix="new-"}}
516
+
>
473
517
```
474
518
519
+
⚠ The `{{element-query}}` modifier adds and removes attributes aggressively and will interfere with other modifiers/libraries manipulating same attributes. It is your duty to ensure there is no conflict in attribute names. Adjust `sizes`, `sizesHeight` and `prefix` arguments to avoid conflicts.
520
+
475
521
476
522
477
523
### Disabling
@@ -896,7 +942,7 @@ Given breakpoints 350, 700 and 1050:
0 commit comments