Skip to content

Commit

Permalink
Add utility classes for opacity (twbs#33781)
Browse files Browse the repository at this point in the history
* Add responsive utility classes for opacity

- fix for twbs#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 <otto@github.com>

* Update site/content/docs/5.0/utilities/opacity.md

Co-authored-by: Mark Otto <otto@github.com>

Co-authored-by: Harish <halodoc@ip-192-168-1-101.ap-southeast-1.compute.internal>
Co-authored-by: XhmikosR <xhmikosr@gmail.com>
Co-authored-by: Mark Otto <otto@github.com>
Co-authored-by: Mark Otto <markd.otto@gmail.com>
Co-authored-by: alpadev <2838324+alpadev@users.noreply.github.com>
  • Loading branch information
6 people authored and marvin-hinkley-vortx committed Aug 18, 2021
1 parent ba6e181 commit fd315fa
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
13 changes: 13 additions & 0 deletions scss/_utilities.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ $utilities: map-merge(
)
),
// scss-docs-end utils-float
// Opacity utilities
// scss-docs-start utils-opacity
"opacity": (
property: opacity,
values: (
0: 0,
25: .25,
50: .5,
75: .75,
100: 1,
)
),
// scss-docs-end utils-opacity
// scss-docs-start utils-overflow
"overflow": (
property: overflow,
Expand Down
30 changes: 30 additions & 0 deletions site/content/docs/5.0/utilities/opacity.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
layout: docs
title: Opacity
description: Control the opacity of elements.
group: utilities
---

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.

Set the `opacity` of an element using `.opacity-{value}` utilities.

<div class="bd-example d-sm-flex">
<div class="opacity-100 p-3 m-2 bg-primary text-light fw-bold rounded">100%</div>
<div class="opacity-75 p-3 m-2 bg-primary text-light fw-bold rounded">75%</div>
<div class="opacity-50 p-3 m-2 bg-primary text-light fw-bold rounded">50%</div>
<div class="opacity-25 p-3 m-2 bg-primary text-light fw-bold rounded">25%</div>
</div>

```html
<div class="opacity-100">...</div>
<div class="opacity-75">...</div>
<div class="opacity-50">...</div>
<div class="opacity-25">...</div>
```

### Utilities API

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" >}})

{{< scss-docs name="utils-opacity" file="scss/_utilities.scss" >}}
1 change: 1 addition & 0 deletions site/data/sidebar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
- title: Flex
- title: Float
- title: Interactions
- title: Opacity
- title: Overflow
- title: Position
- title: Shadows
Expand Down

0 comments on commit fd315fa

Please sign in to comment.