All we're doing is creating an input tag as a React component. We then extract its DOM node and pass it into under the swal function's content option to render it as an unstyled element. The only code that's specific to SweetAlert is the swal.
The rest is just basic React and JavaScript. While the method documented above for creating more advanced modal designs works, it gets quite tedious to manually create nested DOM nodes. That's why we've also made it easy to integrate your favourite template library into SweetAlert, using the SweetAlert Transformer. After that, it's easy. The JSX syntax replaces the modal's content option, so you can still use all of SweetAlert's other features.
Here's how you could implement that Facebook modal that we saw earlier:. SweetAlert 2. The most important change is that callback functions have been deprecated in favour of promises , and that you no longer have to import any external CSS file since the styles are now bundled in the. Your imaginary file has been deleted! What do you want to do? A description for the modal. It can either be added to the object under the key "text" or passed as the second parameter of the function.
The type of the modal. SweetAlert comes with 4 built-in types which will show a corresponding icon animation: " warning ", " error ", " success " and " info". It can either be put in the array under the key "type" or passed as the third parameter of the function. If set to true , a "Cancel"-button will be shown, which the user can click on to dismiss the modal.
Use this to change the text on the "Confirm"-button. If showCancelButton is set as true, the confirm button will automatically show "Confirm" instead of "OK". Set to false if you want the modal to stay open even if the user presses the "Confirm"-button. You seem to have CSS turned off. Please don't fill out this field. Your popup boxes can look exactly how you want them with various options for additional content, custom positioning, animation, background, and so much more! SweetAlert2 also supports various input types and offers a range of different themes.
SweetAlert2 Web Site. Please provide the ad click URL, if possible:. Oh no! Some styles failed to load. Help Create Join Login. Application Development. IT Management. Project Management. Resources Blog Articles.
0コメント