-
-
Notifications
You must be signed in to change notification settings - Fork 78.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expand the Sizing Utility to allow for responsive breakpoints like "w-xl-50" (css, feature, v4) #21943
Comments
Why can't I see and add labels to this issue? |
this pull request fixes this issue #21975 |
We'll pass on this for now, thanks though. |
Only project members of the repository's organization have access to set these. |
I was also looking for this when I first came across the sizing utilities and was disappointed that it didn't exist. Is there a good reason why there are breakpoints for things like spacing, but not this? Otherwise, the sizing utilities are pretty useless by themselves. |
+1 I have lots of this class in bootstrap3. For example on Media object I have 60px image on xs viewport and 80px on larger screens. Now with bootstrap 4 i can just add
And get all this classes.
|
Please this should be a feature it makes my sizing looks dump with viewport |
@mdo Could you elaborate on why we dont need this feature? |
I am also in need for this behavior, any ETA on this? |
Thanks @madmax I just used your code to generate per breakpoints classes into my custom built bootstrap. Any reason why we don't need this feature? it makes a lot of sense to have it. |
Probably because there is not enough interest :( |
I would like to see this behavior added. |
As far as feature requests go, I didn't say you didn't need it—only that we weren't going to do it right now. Adding this means adding 20 classes total. Each new utility balloons our CSS just a little bit more, so I'm always very cautious against adding more of them. |
I support the idea. |
I would like this to be a part of bootstrap |
it Would be quite useful to have that feature |
Yes I just ran across a need for this. |
+1 support |
I would appreciate this being added please |
+1 |
Just another +1 for interest in having this functionality in bootstrap. |
I run into this limitation repeatedly, and just have again, so another +1 |
I'm interested in this new feature 👍 +1 |
Pls |
Very interested. It's just a really basic, missing feature... I assumed it was already there. +1 |
+1 |
1 similar comment
+1 |
@mdo Tailwind CSS supports this with selectors like Please reconsider adding this! |
I have created a simple The only disadvantage is that if you want to specify the property So in order to make it work for devices greater than You have to do like this: here is the link of stylesheet: Live example |
Why is this still not added? This is my most missed feature in Bootstrap. |
+1 |
This can be easily activated in V5 simply by adding this to your variables file: $utilities: (
"width": (
property: width,
responsive: true,
class: w,
values: (
25: 25%,
50: 50%,
75: 75%,
100: 100%,
auto: auto
)
),
"height": (
property: height,
responsive: true,
class: h,
values: (
25: 25%,
50: 50%,
75: 75%,
100: 100%,
auto: auto
)
),
); What would be great is a setting boolean setting to activate the responsive setting without needing to overite the utility. |
Nice... |
Very much needed feature please add it soon. |
I hope the production version of BS5 ship these. |
very good needed feature |
add this to your css: /* Small devices (landscape phones, 576px and up)*/ /* Medium devices (tablets, 768px and up)*/ /* Large devices (desktops, 992px and up)*/ /* Extra large devices (large desktops, 1200px and up)*/ |
If we included this in v4.6.0, and had no plans to support it in v5, would people be opposed? In v5, our column classes are grid agnostic, meaning they can be used for sizing anything, so these utilities would be superfluous. In a v4.6.0 world, we could do |
This is the code to expand the sizing utility
|
@import "~bootstrap/scss/bootstrap-grid.scss"; |
it's work, thank you |
You can modify the map instead of overwrite: $utilities: map-merge(
$utilities,
(
"width": map-merge(
map-get($utilities, "width"),
(
responsive: true
)
)
)
); See https://getbootstrap.com/docs/5.1/utilities/api/#enable-responsive |
it's work😍😍 |
Over 5 years later and it's still not added 👏 |
@MikeEntyce, Any Ideas on how to get them to add it this decade (2020-2030)? |
@anthony0030 very easy (using sass):
|
@madmax, thanks for the fast reply! |
Its still not there in BS 5.2 But thankfully, there are some great devs that provide the missing CSS in this discussion above. |
I just realized that we can use the col-* classes to fix this issue, e.g.
|
5.3 still doesn't have it, absurd! |
Here is a function to deep-set values in SCSS maps. Credits to the original author. /// Deep set function to set a value in nested maps
/// @author Kitty Giraudel
/// @access public
/// @param {Map} $map - Map
/// @param {List} $keys - Key chain
/// @param {*} $value - Value to assign
/// @return {Map}
@function map-deep-set($map, $keys, $value) {
$maps: ($map,);
$result: null;
// If the last key is a map already
// Warn the user we will be overriding it with $value
@if type-of(nth($keys, -1)) == "map" {
@warn "The last key you specified is a map; it will be overridden with `#{$value}`.";
}
// If $keys is a single key
// Just merge and return
@if length($keys) == 1 {
@return map-merge($map, ($keys: $value));
}
// Loop from the first to the second to last key from $keys
// Store the associated map to this key in the $maps list
// If the key doesn't exist, throw an error
@for $i from 1 through length($keys) - 1 {
$current-key: nth($keys, $i);
$current-map: nth($maps, -1);
$current-get: map-get($current-map, $current-key);
@if $current-get == null {
@error "Key `#{$key}` doesn't exist at current level in map.";
}
$maps: append($maps, $current-get);
}
// Loop from the last map to the first one
// Merge it with the previous one
@for $i from length($maps) through 1 {
$current-map: nth($maps, $i);
$current-key: nth($keys, $i);
$current-val: if($i == length($maps), $value, $result);
$result: map-merge($current-map, ($current-key: $current-val));
}
// Return result
@return $result;
} Here is how you enable the responsive classes. $utilities: map-deep-set($utilities, "height" "responsive", true);
$utilities: map-deep-set($utilities, "max-height" "responsive", true);
$utilities: map-deep-set($utilities, "width" "responsive", true);
$utilities: map-deep-set($utilities, "max-width" "responsive", true); This is the best solution I have come up with so far. |
This should be put on top of this thread as a solution, so users do not have to scroll through the rest of comments. |
@smileBeda, Thanks for the compliment! There are other comparable solutions in this thread. It would be great if Bootstrap added a simple sass variable that we could activate for this feature. |
Currently, the Sizing utility (https://getbootstrap.com/docs/4.1/utilities/sizing/) only allows for the sizing of the height or width of an element without regard to the viewport size.
So for instance the "w-50" class makes a lot of sense on a large device in order to limit the width of, for instance, a help text, but not so much on a small device.
This could be resolved by adding breakpoints to the utility in the same way as it is done for the Spacing utility:
This enhancement would not change existing usage, but would allow more flexibility for various device sizes.
Summary: Add support for the following classes:
w-sm-100, w-sm-75, w-sm-50 and w-sm-25
w-md-100, w-md-75, w-md-50 and w-md-25
w-lg-100, w-lg-75, w-lg-50 and w-lg-25
w-xl-100, w-xl-75, w-xl-50 and w-xl-25
h-sm-100, h-sm-75, h-sm-50 and h-sm-25
h-md-100, h-md-75, h-md-50 and h-md-25
h-lg-100, h-lg-75, h-lg-50 and h-lg-25
h-xl-100, h-xl-75, h-xl-50 and h-xl-25
The text was updated successfully, but these errors were encountered: