Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Toggle Pattern

Toggle is a hypermedia control pattern that presents a bi-value, such as on/off or true/false, and offers an affordance to toggle that value from its current state to the opposite state. The Toggle pattern has a Toggle resource that contains the value to toggle. An Action resource toggles the value when triggered. The Action returns a location header pointing back to the modified Toggle resource.

Toggle Resource

profile: <https://level3.rest/patterns/toggle#toggle-resource>

A Data resource that contains the value being toggled. This value can be a field in the data object, or it can be a single value. A Toggle resource can have multiple Togglers, one per field. The links may contain an anchor property indicating the field to be toggled.

toggle

rel="https://level3.rest/patterns/toggle#toggle";anchor="#field-path"

Points to a Toggler resource that toggles the value of the Toggle resource to its opposite value. If present, the anchor property contains a field path to the property being toggled.

Toggler Resource

profile: <https://level3.rest/patterns/toggle#toggler-resource>

An Action resource that toggles the value (or field) of the Toggle resource to its opposite value.

toggles

rel="https://level3.rest/patterns/toggle#toggles";anchor="#field-path"

Points to the Toggle resource that will be toggled. The anchor value in the link contains a path to the field being toggled, if relevant.

Specifications

Web Link Context (anchor): RFC 8288, section 3.2


© 2019-2023 Matt Bishop
Creative Commons Licence
This work is licensed under a Creative Commons Attribution-NoDerivatives 4.0 International License.