Skip to content

Passing props to buttons

If you want to pass any valid HTML attributes to the buttons, for example for adding a disabled attribute or some dataset or aria attributes, you can use the following properties:

  • For buttonYes use the buttonYesAttributes property.
  • For buttonNo use the buttonNoAttributes property.
  • For buttonClose use the buttonCloseAttributes property.
import { useState } from 'react'
import { ConfirmToast } from 'react-confirm-toast'
export function Page() {
const [show, setShow] = useState(false)
function myFunction() {
alert('Done!')
}
const buttonAttributes = { disabled: true, 'aria-label': 'Custom Aria Label' }
return (
<section>
<h1>Page</h1>
<button
onClick={() => {
setShow(true)
}}
>
Click to open ConfirmToast
</button>
<ConfirmToast
buttonYesAttributes={buttonAttributes}
customFunction={myFunction}
setShowConfirmToast={setShow}
showConfirmToast={show}
/>
</section>
)
}