Skip to content

Truthiness

Truthiness keeps class hooks, events, and plugins consistent across patterns. Instead of remembering exact keywords, you can author whatever feels natural and automagicA11y will map it to the canonical state.

💡 Prefix aliases supported: Every example that uses data-automagica11y-* also works with shorthand prefixes like data-automagically-*, data-ama11y-*, or data-automagic-*. The runtime normalizes these aliases before truthiness parsing.

Truthy (open)Falsy (closed)
openclosed
expandedcollapsed
shownhidden
activeinactive
pressedunpressed
truefalse
onoff

Use these tokens after data-automagica11y-trigger-class-* or data-automagica11y-target-class-* and the library will resolve them to the correct boolean.

<button
data-automagica11y-toggle="#faq"
data-automagica11y-trigger-class-expanded="btn--primary"
data-automagica11y-trigger-class-collapsed="btn--ghost"
>
FAQ
</button>

The trigger receives btn--primary whenever the toggle is open, regardless of whether the synonym is expanded, shown, or true.

  • Design tokens stay readable. Use active or hidden if that’s how your team speaks.
  • Plugins stay simple. Lifecycle hooks emit a boolean, so you never translate states manually.
  • Contexts stay compatible. Dialogs, tooltips, and future patterns all share the same mapping.
Custom vocabularies

You can extend truthiness with the context alias system or by registering custom plugins that normalize your own vocabulary before it reaches the registry.