Skip to content

Commit a816615

Browse files
coharishreddyHarishXhmikosRmdoalpadev
authored
Add utility classes for opacity (#33781)
* Add responsive utility classes for opacity - fix for #33483 * remove responsive opacity utils as it has impact on bootstrap.css bundle size * Update opacity.md * Update site/content/docs/5.0/utilities/opacity.md Co-authored-by: Mark Otto <[email protected]> * Update site/content/docs/5.0/utilities/opacity.md Co-authored-by: Mark Otto <[email protected]> Co-authored-by: Harish <[email protected]> Co-authored-by: XhmikosR <[email protected]> Co-authored-by: Mark Otto <[email protected]> Co-authored-by: Mark Otto <[email protected]> Co-authored-by: alpadev <[email protected]>
1 parent 2d8da8b commit a816615

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

scss/_utilities.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ $utilities: map-merge(
2424
)
2525
),
2626
// scss-docs-end utils-float
27+
// Opacity utilities
28+
// scss-docs-start utils-opacity
29+
"opacity": (
30+
property: opacity,
31+
values: (
32+
0: 0,
33+
25: .25,
34+
50: .5,
35+
75: .75,
36+
100: 1,
37+
)
38+
),
39+
// scss-docs-end utils-opacity
2740
// scss-docs-start utils-overflow
2841
"overflow": (
2942
property: overflow,
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
layout: docs
3+
title: Opacity
4+
description: Control the opacity of elements.
5+
group: utilities
6+
---
7+
8+
The `opacity` property sets the opacity level for an element. The opacity level describes the transparency level, where `1` is not transparent at all, `.5` is 50% visible, and `0` is completely transparent.
9+
10+
Set the `opacity` of an element using `.opacity-{value}` utilities.
11+
12+
<div class="bd-example d-sm-flex">
13+
<div class="opacity-100 p-3 m-2 bg-primary text-light fw-bold rounded">100%</div>
14+
<div class="opacity-75 p-3 m-2 bg-primary text-light fw-bold rounded">75%</div>
15+
<div class="opacity-50 p-3 m-2 bg-primary text-light fw-bold rounded">50%</div>
16+
<div class="opacity-25 p-3 m-2 bg-primary text-light fw-bold rounded">25%</div>
17+
</div>
18+
19+
```html
20+
<div class="opacity-100">...</div>
21+
<div class="opacity-75">...</div>
22+
<div class="opacity-50">...</div>
23+
<div class="opacity-25">...</div>
24+
```
25+
26+
### Utilities API
27+
28+
Opacity utilities are declared in our utilities API in `scss/_utilities.scss`. [Learn how to use the utilities API.]({{< docsref "/utilities/api#using-the-api" >}})
29+
30+
{{< scss-docs name="utils-opacity" file="scss/_utilities.scss" >}}

site/data/sidebar.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
- title: Flex
102102
- title: Float
103103
- title: Interactions
104+
- title: Opacity
104105
- title: Overflow
105106
- title: Position
106107
- title: Shadows

0 commit comments

Comments
 (0)