Reference

Configuration

Everything can be adjusted through an attribute on the script tag, or through V.config before the first render. None of it is required: the library works with no configuration at all.

V.config

OptionDefaultWhat it does
prefix'v-'The attribute prefix
autoStarttrueStarts the library when the script loads
autoDiscovertrueWatches the DOM and initializes elements created later
rootnullThe root being watched. With no value, it uses document.body
devtoolsfalseDetailed console warnings and named anchor comments
baseURL''Base URL for the declarative requests
globals{}Extra values allowed inside expressions
localethe browser languageLocale used by the formatters
currency'BRL'Default currency of the formatters
injectStylestrueInjects the CSS of the interface components
cleanAttributestrueStrips the v-* attributes from the HTML once processed
<script src="voodoo.full.min.js" data-manual defer></script>
<script defer>
  V.config.prefix = 'data-v-';
  V.config.locale = 'en-US';
  V.config.currency = 'USD';
  V.config.globals.formatSlug = (text) => text.toLowerCase();
  V.http.setBaseURL('https://api.example.com');
  V.start();
</script>
When the setting has to come first

prefix, autoDiscover, root, cleanAttributes and injectStyles change how the scan behaves. Set them before V.start(), afterwards, what has already been processed does not go back. The globals in V.config.globals take effect when V.start() runs.

Script tag attributes

AttributeEffect
data-manualDoes not start on its own. You call V.start() whenever you want
data-defer-initThe same as data-manual
data-prefixChanges the attribute prefix, for instance to data-v-
data-base-urlBase URL for V.http requests and for the HTTP directives
data-localeThe language used by the date, number and currency formatters
data-devtoolsTurns on detailed console warnings
data-no-stylesDoes not inject the CSS of the interface components
data-no-observerTurns off the MutationObserver that initializes HTML created later
data-keep-attributesKeeps the v-* attributes in the HTML once processed

Lifecycle events

document.addEventListener('voodoo:ready', (e) => {
  console.log('Voodoo', V.version, 'started on', e.detail.root);
});

document.addEventListener('voodoo:theme', (e) => console.log(e.detail.resolved));
document.addEventListener('voodoo:palette', (e) => console.log(e.detail.colors));

CSS tokens

These always exist, with a built-in default value, even without calling V.palette():

TokenWhat it is for
--v-primary, --v-primary-hover, --v-primary-contrastThe main colour
--v-accentThe highlight colour
--v-success, --v-warning, --v-danger, --v-infoStates
--v-surface, --v-surface-2Backgrounds
--v-text, --v-text-mutedText
--v-borderBorders
--v-radius, --v-radius-smRadii
--v-shadowShadow
--v-easeThe easing curve of the transitions
--v-z-modal, --v-z-drawer, --v-z-dropdown, --v-z-toast, --v-z-tooltipLayers

After V.palette(), the set grows:

TokenWhat it is for
--v-surface-3, --v-surface-insetIn-between backgrounds
--v-text-softText softer still
--v-border-strongA higher-contrast border
--v-overlayThe darkened backdrop of the dialogs
--v-shadow-sm, --v-shadow-lgA smaller and a larger shadow
--v-radius-lg, --v-radius-xl, --v-radius-fullLarger radii
--v-focus-ringThe colour of the focus ring
--v-font-sans, --v-font-monoType families
Scales from 50 to 900Shades derived from each base colour

A prefix for strict HTML

<script src="voodoo.full.min.js" data-prefix="data-v-" defer></script>

<div data-v-data="{ n: 0 }">
  <button data-v-click="n++">Add</button>
  <b data-v-text="n"></b>
</div>

The library always accepts data-v-name, even when the configured prefix is a different one. The :attribute and @event shorthands keep working in both modes.