Share via


Container class

A container for other elements. Use containers for styling purposes and/or to logically group a set of elements together, which can be especially useful when used with Action.ToggleVisibility.

Constructors

Container(CardElementArray)

Properties

backgroundImage

Defines the container's background image.

bleed

Controls if the container should bleed into its parent. A bleeding container extends into its parent's padding.

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.

height

The height of the element. When set to stretch, the element will use the remaining vertical space in its container.

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.

items

The elements in the container.

lang

The locale associated with the element.

layouts

The layouts associated with the container. The container can dynamically switch from one layout to another as the card's width changes. See Container layouts for more details.

maxHeight

The maximum height, in pixels, of the container, in the <number>px format. When the content of a container exceeds the container's maximum height, a vertical scrollbar is displayed.

minHeight

The minimum height, in pixels, of the container, in the <number>px format.

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).

roundedCorners

Controls if the container should have rounded corners.

rtl

Controls if the content of the card is to be rendered left-to-right or right-to-left.

selectAction

An Action that will be invoked when the element 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.

showBorder

Controls if a border should be displayed around the container.

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 container. Container styles control the colors of the background, border and text inside the container, in such a way that contrast requirements are always met.

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 Container.

verticalContentAlignment

Controls how the container's content should be vertically aligned.

Methods

withBackgroundImage(string | IBackgroundImage)
withBleed(boolean)
withFallback(FallbackElement)
withHeight(ElementHeight)
withHorizontalAlignment(HorizontalAlignment)
withId(string)
withIsSortKey(boolean)
withIsVisible(boolean)
withItems(CardElementArray)
withLang(string)
withLayouts((IStackLayout | IFlowLayout | IAreaGridLayout)[])
withMaxHeight(string)
withMinHeight(string)
withOptions(ContainerOptions)
withRequires(IHostCapabilities)
withRoundedCorners(boolean)
withRtl(boolean)
withSelectAction(IExecuteAction | IOpenUrlAction | IResetInputsAction | ISubmitAction | IToggleVisibilityAction)
withSeparator(boolean)
withShowBorder(boolean)
withSpacing(Spacing)
withStyle(ContainerStyle)
withTargetWidth(TargetWidth)
withVerticalContentAlignment(VerticalAlignment)

Constructor Details

Container(CardElementArray)

new Container(items: CardElementArray)

Parameters

Property Details

backgroundImage

Defines the container's background image.

backgroundImage?: string | IBackgroundImage

Property Value

string | IBackgroundImage

bleed

Controls if the container should bleed into its parent. A bleeding container extends into its parent's padding.

bleed?: boolean

Property Value

boolean

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

height

The height of the element. When set to stretch, the element will use the remaining vertical space in its container.

height?: ElementHeight

Property Value

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

items

The elements in the container.

items: CardElementArray

Property Value

lang

The locale associated with the element.

lang?: string

Property Value

string

layouts

The layouts associated with the container. The container can dynamically switch from one layout to another as the card's width changes. See Container layouts for more details.

layouts?: (IStackLayout | IFlowLayout | IAreaGridLayout)[]

Property Value

maxHeight

The maximum height, in pixels, of the container, in the <number>px format. When the content of a container exceeds the container's maximum height, a vertical scrollbar is displayed.

maxHeight?: string

Property Value

string

minHeight

The minimum height, in pixels, of the container, in the <number>px format.

minHeight?: 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

roundedCorners

Controls if the container should have rounded corners.

roundedCorners?: boolean

Property Value

boolean

rtl

Controls if the content of the card is to be rendered left-to-right or right-to-left.

rtl?: boolean

Property Value

boolean

selectAction

An Action that will be invoked when the element 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

showBorder

Controls if a border should be displayed around the container.

showBorder?: boolean

Property Value

boolean

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 container. Container styles control the colors of the background, border and text inside the container, in such a way that contrast requirements are always met.

style?: ContainerStyle

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 Container.

type: "Container" = "Container"

Property Value

"Container"

verticalContentAlignment

Controls how the container's content should be vertically aligned.

verticalContentAlignment?: VerticalAlignment

Property Value

Method Details

withBackgroundImage(string | IBackgroundImage)

function withBackgroundImage(backgroundImage: string | IBackgroundImage): Container

Parameters

backgroundImage

string | IBackgroundImage

Returns

withBleed(boolean)

function withBleed(bleed?: boolean): Container

Parameters

bleed

boolean

Returns

withFallback(FallbackElement)

function withFallback(fallback: FallbackElement): Container

Parameters

fallback
FallbackElement

Returns

withHeight(ElementHeight)

function withHeight(height: ElementHeight): Container

Parameters

height
ElementHeight

Returns

withHorizontalAlignment(HorizontalAlignment)

function withHorizontalAlignment(horizontalAlignment: HorizontalAlignment): Container

Parameters

horizontalAlignment
HorizontalAlignment

Returns

withId(string)

function withId(id: string): Container

Parameters

id

string

Returns

withIsSortKey(boolean)

function withIsSortKey(isSortKey?: boolean): Container

Parameters

isSortKey

boolean

Returns

withIsVisible(boolean)

function withIsVisible(isVisible?: boolean): Container

Parameters

isVisible

boolean

Returns

withItems(CardElementArray)

function withItems(items: CardElementArray): Container

Parameters

Returns

withLang(string)

function withLang(lang: string): Container

Parameters

lang

string

Returns

withLayouts((IStackLayout | IFlowLayout | IAreaGridLayout)[])

function withLayouts(layouts: (IStackLayout | IFlowLayout | IAreaGridLayout)[]): Container

Parameters

Returns

withMaxHeight(string)

function withMaxHeight(maxHeight: string): Container

Parameters

maxHeight

string

Returns

withMinHeight(string)

function withMinHeight(minHeight: string): Container

Parameters

minHeight

string

Returns

withOptions(ContainerOptions)

function withOptions(value: ContainerOptions): Container

Parameters

Returns

withRequires(IHostCapabilities)

function withRequires(requires: IHostCapabilities): Container

Parameters

Returns

withRoundedCorners(boolean)

function withRoundedCorners(roundedCorners?: boolean): Container

Parameters

roundedCorners

boolean

Returns

withRtl(boolean)

function withRtl(rtl: boolean): Container

Parameters

rtl

boolean

Returns

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

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

Parameters

Returns

withSeparator(boolean)

function withSeparator(separator?: boolean): Container

Parameters

separator

boolean

Returns

withShowBorder(boolean)

function withShowBorder(showBorder?: boolean): Container

Parameters

showBorder

boolean

Returns

withSpacing(Spacing)

function withSpacing(spacing: Spacing): Container

Parameters

spacing
Spacing

Returns

withStyle(ContainerStyle)

function withStyle(style: ContainerStyle): Container

Parameters

Returns

withTargetWidth(TargetWidth)

function withTargetWidth(targetWidth: TargetWidth): Container

Parameters

targetWidth
TargetWidth

Returns

withVerticalContentAlignment(VerticalAlignment)

function withVerticalContentAlignment(verticalContentAlignment: VerticalAlignment): Container

Parameters

verticalContentAlignment
VerticalAlignment

Returns