Skip to content

Opacity โ€‹

Utilities for controlling the opacity of an element.

Class NameCSS Equivalent
opacity-fullopacity: var(--cds-opacity-full); /* 100% */
opacity-highopacity: var(--cds-opacity-high); /* 87% */
opacity-mediumopacity: var(--cds-opacity-medium); /* 60% */
opacity-lowopacity: var(--cds-opacity-low); /* 38% */
opacity-disabledopacity: var(--cds-opacity-disabled); /* 38% */
opacity-glassopacity: var(--cds-opacity-glass); /* 21% */
opacity-hoveredopacity: var(--cds-opacity-hovered); /* 8% */
opacity-focusedopacity: var(--cds-opacity-focused); /* 12% */
opacity-pressedopacity: var(--cds-opacity-pressed); /* 12% */
opacity-draggedopacity: var(--cds-opacity-dragged); /* 16% */
opacity-noneopacity: var(--cds-opacity-none); /* 0% */

Setting opacity to an element โ€‹

.opacity-full
.opacity-high
.opacity-medium
.opacity-low
.opacity-disabled
.opacity-glass
.opacity-hovered
.opacity-focused
.opacity-pressed
.opacity-dragged
.opacity-none
CEO
Alice Johnson
alice.johnson@company.com
html
<div class="[...] opacity-medium"></div>

Adjusting Text Opacity โ€‹

You can modify the alpha channel of a text color using the text-opacity-{level} utilities. These levels correspond to the opacity levels used for general elements. For example, applying text-opacity-disabled will set the text color to a disabled opacity, aligning with the specified level for general element opacity.

โ— Keep in mind

When configuring the text-opacity-{level} property, it's important to explicitly assign a text color to the text element. This is due to the scoping mechanism of CSS Custom Properties, where opacity can only be set at the same level or a higher level than the specified text color.

For instance, using <h2 class="on-surface text-opacity-medium">title</h2> will apply medium opacity to the on-surface color. However, if wrapped within a <div class="on-surface"><h2 class="text-opacity-medium">title</h2></div>, the opacity level of the h2 title will not be affected, as it is in a different scoping context.

Class NameCSS Equivalent
text-opacity-full--cds-text-opacity: var(--cds-opacity-full); /* 100% */
text-opacity-high--cds-text-opacity: var(--cds-opacity-high); /* 87% */
text-opacity-medium--cds-text-opacity: var(--cds-opacity-medium); /* 60% */
text-opacity-low--cds-text-opacity: var(--cds-opacity-low); /* 38% */
text-opacity-disabled--cds-text-opacity: var(--cds-opacity-disabled); /* 38% */
text-opacity-glass--cds-text-opacity: var(--cds-opacity-glass); /* 21% */
text-opacity-hovered--cds-text-opacity: var(--cds-opacity-hovered); /* 8% */
text-opacity-focused--cds-text-opacity: var(--cds-opacity-focused); /* 12% */
text-opacity-pressed--cds-text-opacity: var(--cds-opacity-pressed); /* 12% */
text-opacity-dragged--cds-text-opacity: var(--cds-opacity-dragged); /* 16% */
text-opacity-none--cds-text-opacity: var(--cds-opacity-none); /* 0% */
.text-opacity-full
.text-opacity-high
.text-opacity-medium
.text-opacity-low
.text-opacity-disabled
.text-opacity-glass
.text-opacity-hovered
.text-opacity-focused
.text-opacity-pressed
.text-opacity-dragged
.text-opacity-none
CEO
Alice Johnson
alice.johnson@company.com
html
<div class="[...] on-surface text-opacity-medium"></div>

Adjusting Background Opacity โ€‹

You can modify the alpha channel of a background color using the bg-opacity-{level} utilities. These levels correspond to the opacity levels used for general elements. For example, applying bg-opacity-disabled will set the background color to a disabled opacity, aligning with the specified level for general element opacity.

โ— Keep in mind

When configuring the bg-opacity-{level} property, it's important to explicitly assign a background color to the element. This is due to the scoping mechanism of CSS Custom Properties, where opacity can only be set at the same level or a higher level than the specified background color.

For instance, using <div class="primary bg-opacity-medium">content</div> will apply medium opacity to the primary background color. However, if wrapped within a <div class="primary"><div class="bg-opacity-medium">content</div></div>, the opacity level of the inner div's background will not be affected, as it is in a different scoping context.

Class NameCSS Equivalent
bg-opacity-full--cds-bg-opacity: var(--cds-opacity-full); /* 100% */
bg-opacity-high--cds-bg-opacity: var(--cds-opacity-high); /* 87% */
bg-opacity-medium--cds-bg-opacity: var(--cds-opacity-medium); /* 60% */
bg-opacity-low--cds-bg-opacity: var(--cds-opacity-low); /* 38% */
bg-opacity-disabled--cds-bg-opacity: var(--cds-opacity-disabled); /* 38% */
bg-opacity-glass--cds-bg-opacity: var(--cds-opacity-glass); /* 21% */
bg-opacity-hovered--cds-bg-opacity: var(--cds-opacity-hovered); /* 8% */
bg-opacity-focused--cds-bg-opacity: var(--cds-opacity-focused); /* 12% */
bg-opacity-pressed--cds-bg-opacity: var(--cds-opacity-pressed); /* 12% */
bg-opacity-dragged--cds-bg-opacity: var(--cds-opacity-dragged); /* 16% */
bg-opacity-none--cds-bg-opacity: var(--cds-opacity-none); /* 0% */
.bg-opacity-full
.bg-opacity-high
.bg-opacity-medium
.bg-opacity-low
.bg-opacity-disabled
.bg-opacity-glass
.bg-opacity-hovered
.bg-opacity-focused
.bg-opacity-pressed
.bg-opacity-dragged
.bg-opacity-none
CEO
Alice Johnson
alice.johnson@company.com
html
<div class="[...] primary bg-opacity-medium"></div>

Adjusting Border Opacity โ€‹

You can modify the alpha channel of a border color using the border-opacity-{level} utilities. These levels correspond to the opacity levels used for general elements. For example, applying border-opacity-disabled will set the border color to a disabled opacity, aligning with the specified level for general element opacity.

โ— Keep in mind

When configuring the border-opacity-{level} property, it's important to explicitly assign a border color to the element. This is due to the scoping mechanism of CSS Custom Properties, where opacity can only be set at the same level or a higher level than the specified border color.

For instance, using <div class="border-primary border-opacity-medium">content</div> will apply medium opacity to the primary border color. However, if wrapped within a <div class="border-primary"><div class="border-opacity-medium">content</div></div>, the opacity level of the inner div's border will not be affected, as it is in a different scoping context.

Class NameCSS Equivalent
border-opacity-full--cds-border-opacity: var(--cds-opacity-full); /* 100% */
border-opacity-high--cds-border-opacity: var(--cds-opacity-high); /* 87% */
border-opacity-medium--cds-border-opacity: var(--cds-opacity-medium); /* 60% */
border-opacity-low--cds-border-opacity: var(--cds-opacity-low); /* 38% */
border-opacity-disabled--cds-border-opacity: var(--cds-opacity-disabled); /* 38% */
border-opacity-glass--cds-border-opacity: var(--cds-opacity-glass); /* 21% */
border-opacity-hovered--cds-border-opacity: var(--cds-opacity-hovered); /* 8% */
border-opacity-focused--cds-border-opacity: var(--cds-opacity-focused); /* 12% */
border-opacity-pressed--cds-border-opacity: var(--cds-opacity-pressed); /* 12% */
border-opacity-dragged--cds-border-opacity: var(--cds-opacity-dragged); /* 16% */
border-opacity-none--cds-border-opacity: var(--cds-opacity-none); /* 0% */
.border-opacity-full
.border-opacity-high
.border-opacity-medium
.border-opacity-low
.border-opacity-disabled
.border-opacity-glass
.border-opacity-hovered
.border-opacity-focused
.border-opacity-pressed
.border-opacity-dragged
.border-opacity-none
CEO
Alice Johnson
alice.johnson@company.com
html
<div class="[...] border-primary border-opacity-medium"></div>