This repository was archived by the owner on Mar 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +37
-1
lines changed
packages/docs/src/mdx/coreComponents Expand file tree Collapse file tree 1 file changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -249,7 +249,7 @@ const MyComponent = () => {
249249 onClose : id => {
250250 console .log (' Dismissed toast with ID: %o' , id )
251251 },
252- }
252+ })
253253 }, [])
254254
255255 return (
@@ -262,6 +262,42 @@ const MyComponent = () => {
262262}
263263```
264264
265+ ## Advanced usage
266+
267+ Not happy with the defaults we've provided? Don't fret. You can create a toast from scratch
268+ as well if you want to.
269+
270+ ``` typescript
271+ import React , { useCallback } from ' react'
272+ import { useToasts , Button } from ' practical-react-components-core'
273+
274+ const MyComponent = () => {
275+ const { showToast } = useToasts ()
276+
277+ const showAdvancedToaster = useCallback (() => {
278+ showToast ({
279+ icon: <Icon icon ={HomeIcon} />,
280+ label: <Typography >Toast label < / Typography > ,
281+ message: <Typography >Toast message < / Typography > ,
282+ // Shows an X the user can click to dismiss the toaster
283+ hasCloseButton: true ,
284+ duration: 10000 ,
285+ onClose : id => {
286+ console .log (' Dismissed toast with ID: %o' , id )
287+ },
288+ })
289+ }, [])
290+
291+ return (
292+ < Button
293+ label = " Custom toaster"
294+ variant = " primary"
295+ onClick = {showAdvancedToaster }
296+ / >
297+ )
298+ }
299+ ```
300+
265301## Props
266302
267303useToasts forwards all unknown props to the base native ` <div> ` component. See
You can’t perform that action at this time.
0 commit comments