Skip to content

Actions should allow an image to be displayed in addition to text for the title #389

@waynehsmith

Description

@waynehsmith

Implementation status

Problem

There's no way to display an image in addition to text on an action. Some hosts, like toast notifications, are built around this experience where developers can provide "image buttons" for their actions.

image

This can NOT be part of the card body. The actions need to be consistently rendered just like actions are today - with the only difference being that an image can be provided.

Card authors should NOT have control over the placement of the image. Otherwise the end user experience would be inconsistent, since some toast notifications would have the image on the left, some on the right, etc.

Spec

Schema changes

We add an iconUrl property to action...

Property Type Required Description
type IAction true
title string true Label for button or link that represents this action
speak Speak false Specifies what should be spoken for this entire element. This is simple text or SSML fragment
iconUrl string false Optional icon to be shown on the action in conjunction with the title
"actions": [
  {
    "type": "Action.Submit",
    "title": "Snooze",
    "iconUrl": "ms-appx:///Assets/Snooze.png",
    "data": "snooze"
  },
  {
    "type": "Action.Submit",
    "title": "Dismiss",
    "iconUrl": "ms-appx:///Assets/Dismiss.png",
    "data": "dismiss"
  }

]

Host Config

"actions": {
    "iconPlacement": "aboveTitle|leftOfTitle",
    "iconSize": 30
}

Defaults: aboveTitle and 30

Update 8/3: iconSize was changed from a string "30px" to a number [30], to match the unit conventions throughout host config. Also updated spec to clarify defaults and some behavior.

Renderer Requirements

  1. If iconPlacement is aboveTitle then the iconSize should be used as the height of the image, while maintaining aspect ratio. Card Authors should use square images for ideal portability between Hosts.
  2. If iconPlacement is leftOfTitle then the image SHOULD BE as close as possible to the height of the text in the action. If that isn't reasonable then iconSize should be used.
  3. If iconUrl is null on ANY action within a set, the iconPlacement SHOULD BE leftOfTitle to ensure buttons are all the same height.
  4. Per-platform styling (CSS, XAML, etc) MUST ADD a new style with a name that combines "ActionWithIcon" appended by the iconPlacement value. E.g., if HostConfig.actions.iconPlacement is "aboveTitle" then the platform style would be "ActionWithIconAboveTitle". This will allow for fine-grained UI treatment of Actions with icons in various placements.

Downlevel Impact

Medium
On a 1.0 renderer the icon will be dropped.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions