-
Notifications
You must be signed in to change notification settings - Fork 60
feat: add opaque buttons and text-opaque utility #3620
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
base: main
Are you sure you want to change the base?
Changes from all commits
8f5313f
e0d8318
85204da
e14f94a
5ed4a2c
c3a7c26
126b447
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -325,6 +325,15 @@ | |
| var(--#{$prefix}color-opacity-transparent), | ||
| var(--#{$prefix}color-content-on-action-loading) | ||
| ); | ||
|
|
||
| &.opacify { | ||
| &:hover, | ||
| &:active, | ||
| &:focus-visible { | ||
| background-color: var(--bs-color-bg-primary); | ||
| background-image: linear-gradient(var(--#{$prefix}btn-hover-bg)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we keep the hover every time ? Where can the specs be found ? |
||
| } | ||
| } | ||
| } | ||
|
|
||
| .btn-negative { | ||
|
|
@@ -526,4 +535,3 @@ | |
| height: var(--#{$prefix}btn-icon-size); | ||
| background-color: currentcolor; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| .text-muted.opacify { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you know if there is a name on design side for this
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no design spec for this |
||
| background-color: var(--bs-color-bg-primary); | ||
| background-clip: text; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -290,6 +290,23 @@ Add `.btn-icon` to get a squared button, meant to only contain an icon. Make sur | |
| </div> | ||
| </div>`} /> | ||
|
|
||
| #### Opaque buttons | ||
|
|
||
| On image background, you can use the `.opacify` class to make buttons more readable. This class adds an opaque background to the button, improving contrast and visibility against complex backgrounds. | ||
|
|
||
| <Callout type="info"> | ||
| The `.opacify` class is only available for `.btn-strong` buttons. | ||
| </Callout> | ||
|
|
||
| <Example buttonLabel="buttons on colored backgrounds" class="p-none bd-btn-example bd-first-rounded" code={`<div class="bg-surface-brand-primary p-large d-flex gap-xsmall flex-wrap" style="background-image: url('https://fastly.picsum.photos/id/628/1000/300.jpg?hmac=scpBB5Z4eJBipw0O_j2T60oQcGjH8xoOA0OG42tW0go')"> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this url something internal that can be used in this context ? shouldn't we get this asset in our repo to avoid depending on external resources ? |
||
| <div data-bs-theme="light" class="d-flex gap-xsmall flex-wrap"> | ||
| <button type="button" class="btn btn-strong opacify">Strong</button> | ||
| </div> | ||
| <div data-bs-theme="dark"> | ||
| <button type="button" class="btn btn-strong opacify">Strong</button> | ||
| </div> | ||
| </div>`} /> | ||
|
|
||
| #### Outline buttons | ||
|
|
||
| <BootstrapCompatibility> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -107,6 +107,20 @@ Take a regular `<a>` element, add `.icon-link`, and insert an icon on the left o | |
| </a>`} /> | ||
| </BootstrapCompatibility> | ||
|
|
||
| ### Opaque links | ||
|
|
||
| On image background, you can use the `.opacify` class to make links more readable. This class adds an opaque background to the link for the `:hover`, `:focus-visible`, and `:active` states, improving contrast and visibility against complex backgrounds. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it apply only on some variants of the links ? |
||
|
|
||
| <Example buttonLabel="links on colored backgrounds" class="p-none bd-btn-example bd-first-rounded" code={`<div class="bg-surface-brand-primary p-large d-flex gap-medium flex-wrap" style="background-image: url('https://fastly.picsum.photos/id/628/1000/300.jpg?hmac=scpBB5Z4eJBipw0O_j2T60oQcGjH8xoOA0OG42tW0go')"> | ||
| <div data-bs-theme="light"> | ||
| <a class="link opacify" href="#">Link</a> | ||
| </div> | ||
| <div data-bs-theme="dark"> | ||
| <a class="link opacify" href="#">Link</a> | ||
| </div> | ||
| </div>`} /> | ||
|
|
||
|
|
||
| ## States | ||
|
|
||
| ### Disabled | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,3 +69,17 @@ See [icons documentation]([[docsref:/components/icon#icons-color]]) to learn how | |
| ## Specificity | ||
|
|
||
| Sometimes contextual classes cannot be applied due to the specificity of another selector. In some cases, a sufficient workaround is to wrap your element’s content in a `<div>` or more semantic element with the desired class. | ||
|
|
||
|
|
||
| ## Opaque text muted | ||
|
|
||
| On image background, you can use the `.opacify` class to make `.text-muted` more readable. This class adds an opaque background to the text, improving contrast and visibility against complex backgrounds. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why on text-muted only ?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's the only semi-transparent color
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We also have |
||
|
|
||
| <Example buttonLabel="links on colored backgrounds" class="p-none bd-btn-example bd-first-rounded" code={`<div class="bg-surface-brand-primary p-large d-flex gap-medium flex-wrap" style="background-image: url('https://fastly.picsum.photos/id/534/1000/300.jpg?hmac=uKVRRoCBPDGUvOZ5ZockbHITRiP-GoVWyQ2WtBpcrB8')"> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A good accessibility practice is to set a background-color close to the color on the image whenever an image is used. Do you think we should add this good practice in our doc ?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok but do we have enough colors for that?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think so |
||
| <div data-bs-theme="light"> | ||
| <p class="text-muted p-small fs-hl opacify">Text muted</p> | ||
| </div> | ||
| <div data-bs-theme="dark"> | ||
| <p class="text-muted p-small fs-hl opacify">Text muted</p> | ||
| </div> | ||
| </div>`} /> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.