@itwin/itwinui-react
Version:
A react component library for iTwinUI
48 lines (47 loc) • 1.76 kB
TypeScript
import * as React from 'react';
import type { ToastProps } from './Toast.js';
export type ToasterSettings = {
/**
* Order of toasts.
* When set to 'descending', most recent toasts are on top. When set to 'ascending', most recent toasts are on bottom.
*
* When set to `auto`, it will behave like 'descending' when `placement` is set to a top value, otherwise 'ascending'.
*
* @default 'auto'
*/
order: 'descending' | 'ascending' | 'auto';
/**
* Placement of toasts.
* Changes placement of toasts. Start indicates left side of viewport. End - right side of viewport.
* @default 'top'
*/
placement: 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end';
};
export type ToastOptions = Omit<ToastProps, 'category' | 'isVisible' | 'id' | 'content'>;
export declare const useToaster: () => {
positive: (content: React.ReactNode, options?: ToastOptions) => {
close: () => void;
};
informational: (content: React.ReactNode, options?: ToastOptions) => {
close: () => void;
};
negative: (content: React.ReactNode, options?: ToastOptions) => {
close: () => void;
};
warning: (content: React.ReactNode, options?: ToastOptions) => {
close: () => void;
};
closeAll: () => void;
setSettings: (settings: Partial<ToasterSettings>) => void;
};
export declare const Toaster: () => React.JSX.Element;
export declare const ToastProvider: ({ children, inherit, }: {
children: React.ReactNode;
inherit?: boolean;
}) => React.JSX.Element;
export declare const ToasterStateContext: React.Context<ToasterState | undefined>;
type ToasterState = {
toasts: ToastProps[];
settings: ToasterSettings;
};
export {};