@styleless-ui/react
Version:
Completely unstyled, headless and accessible React UI components.
53 lines (52 loc) • 1.72 kB
TypeScript
import * as React from "react";
import type { MergeElementProps } from "../typings";
interface OwnProps {
/**
* The content of the snackbar.
*/
children?: React.ReactNode;
/**
* The className applied to the snackbar.
*/
className?: string | ((ctx: {
openState: boolean;
}) => string);
/**
* If `true`, the snackbar will be opened.
*/
open: boolean;
/**
* The DOM node reference or selector to focus when the snackbar closes.
*
* If not provided, the previously focused element will be focused.
*/
focusAfterClosed?: React.RefObject<HTMLElement> | string;
/**
* The `status` role defines a live region containing advisory information for the user that is not important enough to be an `alert`.
*
* The `alert` role is for important, and usually time-sensitive, information.
* @default "alert"
*/
role: "alert" | "status";
/**
* Used to keep mounting when more control is needed.\
* Useful when controlling animation with React animation libraries.
* @default false
*/
keepMounted?: boolean;
/**
* The time in milliseconds that should elapse before automatically closing the snackbar.
*/
duration?: number;
/**
* The Callback is fired when the duration ends.
*/
onDurationEnd?: () => void;
/**
* Callback fired when the `Escape` key is released.
*/
onEscapeKeyUp?: (event: KeyboardEvent) => void;
}
export type Props = Omit<MergeElementProps<"div", OwnProps>, "defaultChecked" | "defaultValue">;
declare const Snackbar: (props: Props, ref: React.Ref<HTMLDivElement>) => JSX.Element | null;
export default Snackbar;