--- url: /reference/items/Frame.md --- # Frame ## Usage The `Frame` component and its children `FrameForm`, `FrameTarget`, `FrameAnchor` and `FrameLoader` perform GET or POST requests without reloading the page. Only include the `Frame` component in your app, as it loads all the others automatically. ```js twoslash import { registerComponent } from '@studiometa/js-toolkit'; import { Frame } from '@studiometa/ui'; registerComponent(Frame); ``` ### Frame Orchestrates request handling, browser history updates, and related tasks. The component **must have** an `id` attribute. The component works only with its children `FrameForm`, `FrameTarget`, `FrameAnchor` and `FrameLoader`. ```html
Loading...
Loading... My foo bar link
``` ::: warning ❗ Important The root element of a `Frame` component **must have an `id` attribute**. It is used to map new content to the existing one. ::: ### FrameForm The `FrameForm` component should **only be used on a `HTMLFormElement`**. It will use the standard `
` APIs to send a request: * the [`action` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/form#action) defines the URL * the [`method` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/form#method) defines the method (only `GET` or `POST` methods are supported for now) * the named ``, `
``` ### FrameTarget This component indicate which part of the document should be updated once the request is performed. Only content inside a `FrameTarget` will change when a request is done. ```html
``` ::: warning ❗ Important The root element of a `FrameTarget` component **must have an `id` attribute**. It is used to map new content to the existing one. ::: ### FrameAnchor This component can be used to intercept navigation via URL links. ```html My foo bar link ``` ::: warning ❗ Important The root element of a `FrameAnchor` component **must be an `` element**. ::: When clicking on this `FrameAnchor` a fetch request will be send to the URL defined by the `href` attribute. ### FrameLoader The `FrameLoader` component can be used to display a loader during the AJAX request. ```html
Loading...
``` ### FrameTriggerLoader Like the `FrameLoader` component, the `FrameTriggerLoader` component can be used to display a loader during a request. It will be attached to the closest trigger component (`FrameAnchor` or `FrameForm`) and displayed only when the request being made comes from this trigger. ```html {2-8}
Loading... Click me! ``` ::: warning ❗ Important The `FrameTriggerLoader` should be placed inside a `FrameForm` or `FrameAnchor` component, it will have no effect otherwise. :::