Providing btn stylings as placeholder/silent classes
See original GitHub issuePrerequisites
- I have searched for duplicate or closed feature requests
- I have read the contributing guidelines
Proposal
Placeholders or silent classes(%
-prefix) are blocks that contain stylings but are not rendered to CSS if not used by a class.
I propose adding silent classes to all basic button stylings in scss/_buttons.scss
, so they can be extended from without bloat.
Example:
.btn, %btn {
// button stylings here
}
Motivation and context
We use external JavaScripts that embed own HTML structures that do not use Bootstrap.
We then apply the Bootstrap button stylings to the elements via @extend
:
.external-component-button {
@extends .btn;
}
The issue is that extending classes will extend ALL usages of the .btn class, even nested ones. This results in a multitude of selectors that are not even needed (bloated selectors). The solution is extending from a silent class aka placeholder:
.external-component-button {
@extends %btn;
}
More information on that topic here: https://jdsteinbach.com/sass/use-extend/
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Sass: Placeholders and @extend-Only Selectors
Placeholders act like silent classes in that they allow you to use @extend to inherit styles, but those styles won't compile to CSS...
Read more >Extending Placeholder Selectors with Sass - Treehouse Blog
Sass 3.2 introduced a special feature called placeholder selectors. They're also referred to as “silent classes” because they won't appear in ...
Read more >SASS scss - Overriding an existing placeholder (silent class)
I must not be understanding something to think that SASS does not allow for overriding of an existing silent class (placeholder) ...
Read more >placeholder - CSS: Cascading Style Sheets - MDN Web Docs
The ::placeholder CSS pseudo-element represents the placeholder text in an or element.
Read more >How the spec says to implement silent mode for SASS · Issue #188 ...
This is simpler than trying to wrap a bunch of styles in a 'placeholder or optional class selector'. It may even be better...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think this is something that’s tabled for discussion in v5—would be too much overhead IMO. I also have decently strong feelings against extend in general, so we’d need to weigh the pros and cons more deeply across all our components.
Closing for now and labelling for v6 to revisit for then.
Honestly I don’t know, but AFAIK this hasn’t been requested before—but I didn’t check.
Moving to this would be a tough work. In your case, workarounds exist and the issue is not with Bootstrap but with another script adding markup roughly.
Bootstrap is meant to apply on specific markup, handling other markup is out scope. And I’m really concerned about what could come next, if we try to take such cases into account.