Background color support for images
See original GitHub issueImplementation status
- TypeScript (available with the Outlook container in the visualizer)
- UWP (#1412)
- .NET (#1415)
- iOS (#1414)
- Android (#1413)
- Documentation
Problem
Often, it is necessary to present one single image on top of a variety of different background colors. It is in general not practical to either have to dynamically generate the appropriate image server-side or to have to store all possible combinations somewhere.
Solution
Add a backgroundColor property to the Image element. With that, a card author can lay an image with a transparent background on top of any color they want. The background color respects the image’s style, e.g. when set to “person”, which crops the image to a circle, the background color is clipped to the circle.
Example:
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "Image",
"size": "medium",
"url": "http://messagecardplayground.azurewebsites.net/assets/circleontransparentbackground.png",
"backgroundColor": "#CCCCCC"
},
{
"type": "Image",
"size": "medium",
"url": "http://messagecardplayground.azurewebsites.net/assets/circleontransparentbackground.png",
"backgroundColor": "#DDDDDD",
"style": "person"
}
]
}
The above payload renders the same image on two different colors using the both supported image styles:
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
background-image - CSS: Cascading Style Sheets | MDN
The background-image CSS property sets one or more background images on an element.
Read more >CSS: background image on background color
I set the panel to blue with the css background: #6DB3F2; and the background image with background-image: url('images/checked.png') . But it ...
Read more >Change Background Color of Photo Online in 1 Click
With Fotor's free online background color changer, you can change background color of photo to white, blue, black and any other color in...
Read more >CSS background-image property
The background-image property sets one or more background images for an element. By default, a background-image is placed at the top-left corner of...
Read more >Tinted Images with Multiple Backgrounds
Tinted Images with Multiple Backgrounds ... The background property in CSS can accept comma separated values. “Multiple” backgrounds, if you will.
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
Did we think about accessibility for this?
For images, we have ideas in place for how we could append query strings to request high contrast versions of the image, allowing the author to provide a different image for high contrast… but we currently don’t have a way to allow the author to provide a different background color for high contrast.
I suppose the backgroundColor property could also be an object that includes “normal” and “highContrast” colors?
I’ll add this to the accessibility bucket list.
Documentation is done and in the mahiding/site1.1 branch.