diff --git a/www/examples.md b/www/examples.md index 8b06d148..b417c30f 100644 --- a/www/examples.md +++ b/www/examples.md @@ -21,6 +21,8 @@ You can copy and paste them and then adjust them for your needs. | [Active Search](/examples/active-search) | Demonstrates the active search box pattern | [Progress Bar](/examples/progress-bar) | Demonstrates a job-runner like progress bar | [Value Select](/examples/value-select) | Demonstrates making the values of a select dependent on another select -| [Dialogs](/examples/dialogs) | Demonstrates the prompt and confirm dialogs | [Animations](/examples/animations) | Demonstrates various animation techniques +| [Dialogs - Browser](/examples/dialogs) | Demonstrates the prompt and confirm dialogs +| [Dialogs - UIKIt](/examples/modal-uikit) | Demonstrates modal dialogs using UIKit | [Dialogs - Bootstrap](/examples/modal-bootstrap) | Demonstrates modal dialogs using Bootstrap + diff --git a/www/examples/modal-uikit.md b/www/examples/modal-uikit.md new file mode 100644 index 00000000..33a83be7 --- /dev/null +++ b/www/examples/modal-uikit.md @@ -0,0 +1,135 @@ +--- +layout: demo_layout.njk +--- + +## Modal Dialogs + +Many CSS toolkits include styles (and Javascript) for creating modal dialog boxes. +This example shows how to use HTMX to display dynamic dialog using UIKit, and how to +trigger its animation styles with little or no Javascript. + +We start with a button that triggers the dialog, along with a DIV at the bottom of your +markup where the dialog will be loaded: + +This is an example of using HTMX to remotely load modal dialogs using UIKit. + +```html + + +
+``` + +This button uses a `GET` request to `/uikit-modal.html` when this button is clicked. The +contents of this file will be added to the DOM underneath the `#show-modals-here` DIV. + +We're replacing the standard UIKit Javascript library with a little bit of Hyperscript, +which triggers UIKit's smooth animations. It is delayed by 10ms so that UIKit's animations +will run correctly. + +Finally, the server responds with a slightly modified version of UIKit's standard modal + +```html +This modal dialog was loaded dynamically by HTMX.
+ + +