Share via


Icon class

A standalone icon element. Icons can be picked from the vast Adaptive Card icon catalog.

Constructors

Icon(string, IconOptions)

Properties

color

The color of the icon.

fallback

An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property.

grid.area

The area of a Layout.AreaGrid layout in which an element should be displayed.

horizontalAlignment

Controls how the element should be horizontally aligned.

id

A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot.

isSortKey

Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements.

isVisible

Controls the visibility of the element.

lang

The locale associated with the element.

name

The name of the icon to display.

requires

A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided).

selectAction

An Action that will be invoked when the icon is tapped or clicked. Action.ShowCard is not supported.

separator

Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true.

size

The size of the icon.

spacing

Controls the amount of space between this element and the previous one. No space will be added for the first element in a container.

style

The style of the icon.

targetWidth

Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see Responsive layout.

type

Must be Icon.

Methods

from(Omit<IIcon, "type">)
withColor(TextColor)
withFallback(FallbackElement)
withHorizontalAlignment(HorizontalAlignment)
withId(string)
withIsSortKey(boolean)
withIsVisible(boolean)
withLang(string)
withName(string)
withRequires(IHostCapabilities)
withSelectAction(IExecuteAction | IOpenUrlAction | IResetInputsAction | ISubmitAction | IToggleVisibilityAction)
withSeparator(boolean)
withSize(IconSize)
withSpacing(Spacing)
withStyle(IconStyle)
withTargetWidth(TargetWidth)

Constructor Details

Icon(string, IconOptions)

new Icon(name: string, options?: IconOptions)

Parameters

name

string

options
IconOptions

Property Details

color

The color of the icon.

color?: TextColor

Property Value

fallback

An alternate element to render if the type of this one is unsupported or if the host application doesn't support all the capabilities specified in the requires property.

fallback?: FallbackElement

Property Value

grid.area

The area of a Layout.AreaGrid layout in which an element should be displayed.

grid.area?: string

Property Value

string

horizontalAlignment

Controls how the element should be horizontally aligned.

horizontalAlignment?: HorizontalAlignment

Property Value

id

A unique identifier for the element or action. Input elements must have an id, otherwise they will not be validated and their values will not be sent to the Bot.

id?: string

Property Value

string

isSortKey

Controls whether the element should be used as a sort key by elements that allow sorting across a collection of elements.

isSortKey?: boolean

Property Value

boolean

isVisible

Controls the visibility of the element.

isVisible?: boolean

Property Value

boolean

lang

The locale associated with the element.

lang?: string

Property Value

string

name

The name of the icon to display.

name: string

Property Value

string

requires

A list of capabilities the element requires the host application to support. If the host application doesn't support at least one of the listed capabilities, the element is not rendered (or its fallback is rendered if provided).

requires?: IHostCapabilities

Property Value

selectAction

An Action that will be invoked when the icon is tapped or clicked. Action.ShowCard is not supported.

selectAction?: IExecuteAction | IOpenUrlAction | IResetInputsAction | ISubmitAction | IToggleVisibilityAction

Property Value

separator

Controls whether a separator line should be displayed above the element to visually separate it from the previous element. No separator will be displayed for the first element in a container, even if this property is set to true.

separator?: boolean

Property Value

boolean

size

The size of the icon.

size?: IconSize

Property Value

spacing

Controls the amount of space between this element and the previous one. No space will be added for the first element in a container.

spacing?: Spacing

Property Value

style

The style of the icon.

style?: IconStyle

Property Value

targetWidth

Controls for which card width the element should be displayed. If targetWidth isn't specified, the element is rendered at all card widths. Using targetWidth makes it possible to author responsive cards that adapt their layout to the available horizontal space. For more details, see Responsive layout.

targetWidth?: TargetWidth

Property Value

type

Must be Icon.

type: "Icon" = "Icon"

Property Value

"Icon"

Method Details

from(Omit<IIcon, "type">)

static function from(options: Omit<IIcon, "type">): Icon

Parameters

options

Omit<IIcon, "type">

Returns

withColor(TextColor)

function withColor(color: TextColor): Icon

Parameters

color
TextColor

Returns

withFallback(FallbackElement)

function withFallback(fallback: FallbackElement): Icon

Parameters

fallback
FallbackElement

Returns

withHorizontalAlignment(HorizontalAlignment)

function withHorizontalAlignment(horizontalAlignment: HorizontalAlignment): Icon

Parameters

horizontalAlignment
HorizontalAlignment

Returns

withId(string)

function withId(id: string): Icon

Parameters

id

string

Returns

withIsSortKey(boolean)

function withIsSortKey(isSortKey?: boolean): Icon

Parameters

isSortKey

boolean

Returns

withIsVisible(boolean)

function withIsVisible(isVisible?: boolean): Icon

Parameters

isVisible

boolean

Returns

withLang(string)

function withLang(lang: string): Icon

Parameters

lang

string

Returns

withName(string)

function withName(name: string): Icon

Parameters

name

string

Returns

withRequires(IHostCapabilities)

function withRequires(requires: IHostCapabilities): Icon

Parameters

Returns

withSelectAction(IExecuteAction | IOpenUrlAction | IResetInputsAction | ISubmitAction | IToggleVisibilityAction)

function withSelectAction(selectAction: IExecuteAction | IOpenUrlAction | IResetInputsAction | ISubmitAction | IToggleVisibilityAction): Icon

Parameters

Returns

withSeparator(boolean)

function withSeparator(separator?: boolean): Icon

Parameters

separator

boolean

Returns

withSize(IconSize)

function withSize(size: IconSize): Icon

Parameters

size
IconSize

Returns

withSpacing(Spacing)

function withSpacing(spacing: Spacing): Icon

Parameters

spacing
Spacing

Returns

withStyle(IconStyle)

function withStyle(style: IconStyle): Icon

Parameters

style
IconStyle

Returns

withTargetWidth(TargetWidth)

function withTargetWidth(targetWidth: TargetWidth): Icon

Parameters

targetWidth
TargetWidth

Returns