diff --git a/www/examples.md b/www/examples.md index d15fb923..9ba15811 100644 --- a/www/examples.md +++ b/www/examples.md @@ -25,5 +25,7 @@ You can copy and paste them and then adjust them for your needs. | [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 +| [Tabs (Using HATEOAS)](/examples/tabs-hateoas) | Demonstrates how to display and select tabs using HATEOAS principles +| [Tabs (Using Hyperscript)](/examples/tabs-hyperscript) | Demonstrates how to display and select tabs using Hyperscript | [File Upload](/examples/file-upload) | Demonstrates how to upload a file via ajax with a progress bar diff --git a/www/examples/tabs-hateoas.md b/www/examples/tabs-hateoas.md new file mode 100644 index 00000000..b55ade13 --- /dev/null +++ b/www/examples/tabs-hateoas.md @@ -0,0 +1,119 @@ +--- +layout: demo_layout.njk +--- + +## Tabs (Using HATEOAS) + +This example shows how easy it is to implement tabs using htmx. Following the principle of [Hypertext As The Engine Of Application State](https://en.wikipedia.org/wiki/HATEOAS), the selected tab is a part of the application state. Therefore, to display and select tabs in your application, simply include the tab markup in the returned HTML. If this does not suit your application server design, you can also use a little bit of [Javascript to select tabs instead](../tabs-javascript). + +### Example Code (Main Page) +The main page simply includes the following HTML to load the initial tab into the DOM. +```html +
+``` + +### Example Code (Each Tab) +Subsequent tab pages display all tabs and highlight the selected one accordingly. + +```html + + +