Skip to content

Custom Toast question #1977

Sep 7, 2020 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

You can use the default toast UI with disabling the auto close and the built-in close button:

const CloseToastDemo = () => {
  const toast = useToast();

  function showToast() {
    toast({
      title: "Hello there",
      isClosable: true, // shows a close button
      duration: null // disables auto close
    });
  }

  return <Button onClick={showToast}>Show Toast</Button>;
};

or you can define a custom render function for your toast and close it with the onClose function.

const CloseToastDemo = () => {
  const toast = useToast();

  function showToast() {
    toast({
      duration: null, // disables auto close
      render: ({ onClose }) => (
        <Box>
          <Text>Hello there<

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ljosberinn
Comment options

@TimKolberger
Comment options

Answer selected by ljosberinn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants