Skip to content
Zotonic
  • Start
  • Cookbook
  • Reference
  • Releases

Live search

Search across all Zotonic content

Type at least two characters

Results are matched against titles, summaries and topics as you type.

Actions · mod_wires
  • Reference
  • Frontend developer
  • User interface and interaction
  • Wire action
  • JavaScript

toggle_class

Module

mod_wires

Toggle a CSS class from an HTML element.

Example:

{% button action={toggle_class target="myid" class="newclass"} %}

When the HTML element with id “myid” has the CSS class “newclass” then it is removed, otherwise it is added.

Edit on GitHub

Related pages

  • add_class Add a css class to an html element. →
  • remove_class Remove a CSS class from an HTML element. →

Related documentation

Cotonic models

model/wires Cotonic

model/wires Connects Cotonic messages to named Zotonic events through the wires script.

Actions

alert

Show an alert dialog.

Actions

enable

Resets the “disabled” attribute of a HTML tag and removes the CSS class “disabled”.

Actions

mask

Places a mask over an element, useful for blocking user interaction during lengthy postbacks.

Scomp

wire_args

Add extra arguments to wired actions.

Scomp

sortable

Mark an element as sortable.

Actions

disable

Sets the “disabled” attribute of a HTML tag and adds the CSS class “disabled”.

Actions

overlay_open

Renders a template on the server and opens a full screen overlay with the HTML output of the template.

Actions

overlay_close

Closes the currently open overlay. When there is no overlay open then nothing happens.

GitHub © 2026 Zotonic