A timed notification with keyboard dismissal and accessible announcements.
import { useState } from 'react';
import { Toast } from '@vrum/ui';
import { ToastTitle, ToastDescription, ToastClose } from '@vrum/ui';
import { ToastProvider, ToastViewport } from '@vrum/ui';
export default function Demo() {
const [open, setOpen] = useState(false);
return (
<ToastProvider>
<Toast
open={open}
variant={"success"}
duration={4000}
onOpenChange={setOpen}
>
<ToastTitle>Project updated</ToastTitle><ToastDescription>Your changes have been saved.</ToastDescription><ToastClose />
</Toast>
<ToastViewport />
</ToastProvider>
);
}Copy code| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | none | Controlled visibility. |
defaultOpen | boolean | none | Initial visibility for an uncontrolled component. |
onOpenChange | ((open: boolean) => void) | none | Called when visibility changes. |
forceMount | true | none | Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries. |
asChild | boolean | none | as child configuration. |
type | ToastType | none | type configuration. |
value | string | number | readonly string[] | none | Controlled value. |
defaultChecked | boolean | none | default checked configuration. |
defaultValue | string | number | readonly string[] | none | Initial value for an uncontrolled component. |
autoFocus | boolean | none | auto focus configuration. |
className | string | none | Additional CSS classes. |
id | string | none | id configuration. |
style | CSSProperties | none | Inline style overrides. |
aria-invalid | boolean | "false" | "true" | "grammar" | "spelling" | none | Indicates the entered value does not conform to the format expected by the application. |
aria-label | string | none | Defines a string value that labels the current element. |
children | ReactNode | none | Content rendered inside the component. |
onFocus | FocusEventHandler<HTMLLIElement> | none | on focus configuration. |
onBlur | FocusEventHandler<HTMLLIElement> | none | on blur configuration. |
onChange | ChangeEventHandler<HTMLLIElement, Element> | none | Called when the input value changes. |
onSubmit | SubmitEventHandler<HTMLLIElement> | none | Called when the form is submitted. |
onKeyDown | KeyboardEventHandler<HTMLLIElement> | none | on key down configuration. |
onPause | (() => void) | none | on pause configuration. |
onClick | MouseEventHandler<HTMLLIElement> | none | Called when the control is activated. |
onSelect | ReactEventHandler<HTMLLIElement> | none | on select configuration. |
onEscapeKeyDown | ((event: KeyboardEvent) => void) | none | on escape key down configuration. |
duration | number | none | duration configuration. |
onResume | (() => void) | none | on resume configuration. |
onSwipeStart | ((event: SwipeEvent) => void) | none | on swipe start configuration. |
onSwipeMove | ((event: SwipeEvent) => void) | none | on swipe move configuration. |
onSwipeCancel | ((event: SwipeEvent) => void) | none | on swipe cancel configuration. |
onSwipeEnd | ((event: SwipeEvent) => void) | none | on swipe end configuration. |
variant | "default" | "success" | "warning" | "info" | "error" | "default" | Visual appearance within the Vrum design system. |
| Prop | Type | Default | Description |
|---|---|---|---|
asChild | boolean | none | as child configuration. |
defaultChecked | boolean | none | default checked configuration. |
defaultValue | string | number | readonly string[] | none | Initial value for an uncontrolled component. |
autoFocus | boolean | none | auto focus configuration. |
className | string | none | Additional CSS classes. |
id | string | none | id configuration. |
style | CSSProperties | none | Inline style overrides. |
aria-invalid | boolean | "false" | "true" | "grammar" | "spelling" | none | Indicates the entered value does not conform to the format expected by the application. |
aria-label | string | none | Defines a string value that labels the current element. |
children | ReactNode | none | Content rendered inside the component. |
onFocus | FocusEventHandler<HTMLDivElement> | none | on focus configuration. |
onBlur | FocusEventHandler<HTMLDivElement> | none | on blur configuration. |
onChange | ChangeEventHandler<HTMLDivElement, Element> | none | Called when the input value changes. |
onSubmit | SubmitEventHandler<HTMLDivElement> | none | Called when the form is submitted. |
onKeyDown | KeyboardEventHandler<HTMLDivElement> | none | on key down configuration. |
onClick | MouseEventHandler<HTMLDivElement> | none | Called when the control is activated. |
onSelect | ReactEventHandler<HTMLDivElement> | none | on select configuration. |
| Prop | Type | Default | Description |
|---|---|---|---|
asChild | boolean | none | as child configuration. |
defaultChecked | boolean | none | default checked configuration. |
defaultValue | string | number | readonly string[] | none | Initial value for an uncontrolled component. |
autoFocus | boolean | none | auto focus configuration. |
className | string | none | Additional CSS classes. |
id | string | none | id configuration. |
style | CSSProperties | none | Inline style overrides. |
aria-invalid | boolean | "false" | "true" | "grammar" | "spelling" | none | Indicates the entered value does not conform to the format expected by the application. |
aria-label | string | none | Defines a string value that labels the current element. |
children | ReactNode | none | Content rendered inside the component. |
onFocus | FocusEventHandler<HTMLDivElement> | none | on focus configuration. |
onBlur | FocusEventHandler<HTMLDivElement> | none | on blur configuration. |
onChange | ChangeEventHandler<HTMLDivElement, Element> | none | Called when the input value changes. |
onSubmit | SubmitEventHandler<HTMLDivElement> | none | Called when the form is submitted. |
onKeyDown | KeyboardEventHandler<HTMLDivElement> | none | on key down configuration. |
onClick | MouseEventHandler<HTMLDivElement> | none | Called when the control is activated. |
onSelect | ReactEventHandler<HTMLDivElement> | none | on select configuration. |
| Prop | Type | Default | Description |
|---|---|---|---|
asChild | boolean | none | as child configuration. |
disabled | boolean | none | Disable user interaction. |
name | string | none | name configuration. |
type | "submit" | "reset" | "button" | none | type configuration. |
value | string | number | readonly string[] | none | Controlled value. |
defaultChecked | boolean | none | default checked configuration. |
defaultValue | string | number | readonly string[] | none | Initial value for an uncontrolled component. |
autoFocus | boolean | none | auto focus configuration. |
className | string | none | Additional CSS classes. |
id | string | none | id configuration. |
style | CSSProperties | none | Inline style overrides. |
aria-invalid | boolean | "false" | "true" | "grammar" | "spelling" | none | Indicates the entered value does not conform to the format expected by the application. |
aria-label | string | none | Defines a string value that labels the current element. |
children | ReactNode | none | Content rendered inside the component. |
onFocus | FocusEventHandler<HTMLButtonElement> | none | on focus configuration. |
onBlur | FocusEventHandler<HTMLButtonElement> | none | on blur configuration. |
onChange | ChangeEventHandler<HTMLButtonElement, Element> | none | Called when the input value changes. |
onSubmit | SubmitEventHandler<HTMLButtonElement> | none | Called when the form is submitted. |
onKeyDown | KeyboardEventHandler<HTMLButtonElement> | none | on key down configuration. |
onClick | MouseEventHandler<HTMLButtonElement> | none | Called when the control is activated. |
onSelect | ReactEventHandler<HTMLButtonElement> | none | on select configuration. |