Toast
import {Toast} from 'cx/widgets';The Toast widget is used to inform the users about new events and offer quick actions. Toasts are similar
to Overlays, with the difference that toast position is controlled by the framework.
<Button onClick={ (e, ins) => createToast(e, ins, {placement: 'left'})}>Left Toast</Button>
<Button onClick={ (e, ins) => createToast(e, ins, {placement: 'right'})}>Right Toast</Button>
<Button onClick={ (e, ins) => createToast(e, ins, {placement: 'top'})}>Top Toast</Button>
<Button onClick={ (e, ins) => createToast(e, ins, {placement: 'bottom'})}>Bottom Toast</Button>
<Button onClick={ (e, {store}) => store.toggle('$page.toast.visible')}>Toggle Toast</Button>
<Button onClick={ (e, {store}) => store.toggle('$page.complex.visible')}>Complex Toast</Button>
<Button onClick={ (e, ins) => createToast(e, ins, {mod: 'primary'})}>Primary Mod</Button>
<Button onClick={ (e, ins) => createToast(e, ins, {mod: 'warning'})}>Warning Mod</Button>
<Button onClick={ (e, ins) => createToast(e, ins, {mod: 'error'})}>Error Mod</Button>
<Button onClick={ (e, ins) => createToast(e, ins, {mod: 'success'})}>Success Mod</Button>
<Toast visible-bind="$page.toast.visible" preserveWhitespace>
This toast is visible only on this page.
<Button icon="close" dismiss mod="hollow" tooltip="Close"/>
</Toast>
<Toast visible-bind="$page.complex.visible" preserveWhitespace>
<div preserveWhitespace>
<TextField value-bind="$page.name" label="Quick Reply:" />
<Button icon="envelope-o" dismiss disabled-expr="{$page.name} == null">Send</Button>
<Button icon="close" dismiss />
</div>
</Toast>| Property | Description | Type |
|---|---|---|
closeOnEscape | Set to | boolean |
placement | Defines where the toast will be placed.
Supported values are | string |
timeout | Value of timeout in milliseconds after which the toast is automatically dismissed. | number |
autoFocus | Set to | boolean |
autoFocusFirstChild | Set to | boolean |
baseClass | Base CSS class. Default is | string |
centerX | Set to | boolean |
centerY | Set to | boolean |
class | Additional CSS classes to be applied to the element. If an object is provided, all keys with a "truthy" value will be added to the CSS class list. | string/object |
containerStyle | Style to be applied to the overlay's container element. | string |
destroyDelay | Number of milliseconds to wait, before removing the element from the DOM. Used in combination with the | number |
dismissOnFocusOut | Set to | boolean |
dismissOnPopState | Set to | boolean |
focusable | Set to true to make the top level overlay element focusable. | boolean |
items | List of child elements. | array |
layout | Define an inner layout. | string/object |
mod | Appearance modifier. For example, | string/array |
onMove | A callback function which fires while the overlay is being moved around. | function |
onResize | A callback function which fires while the overlay is being resized. | function |
pad | Add default padding. Default is | boolean |
plainText | Set to | boolean |
preserveWhitespace | Keep whitespace in text based children. Default is | boolean |
putInto | Used with outer layouts. Specifies the name of the content placeholder which should render the widget. | string |
resizeWidth | resizeWidth | number |
style | Style object applied to the wrapper div. Used for setting the dimensions of the element. | string/object |
trimWhitespace | Remove all whitespace in text based children. Default is | boolean |
vdomKey | Key that will be used as the key when rendering the React component. | string |
visible | Visibility of the widget. Defaults to | boolean |
zIndex | zIndex | number |