Documentation · reference

Theming

Tokens, presets, layouts, framework adapters and custom themes.

Theming

plugin-core.css contains structure only: layout, positioning, the 1×1 px native-input mechanism and visibility rules. Every colour, border, shadow and skin is in plugin-theme.css, driven by --zs-* custom properties.

Load order:

<link rel="stylesheet" href="plugin-core.css">
<link rel="stylesheet" href="plugin-theme.css">
<link rel="stylesheet" href="my-theme.css">   <!-- optional overrides -->

Resolution order

LevelWins over
style="--zs-primary: …"everything
data-zs-theme / data-zs-framework on the control wrapperancestors
Wrapper (form, section) attributes<html>
<html data-zs-theme="dark" data-zs-framework="bootstrap">theme defaults

Themes and frameworks resolve independently: you can combine dark + bootstrap.

Presets

<form data-zs-theme="dark">
PresetCharacter
defaultNeutral greys, indigo #4f6bed, 10px radius.
modernSofter indigo, 12px radius, layered shadows.
minimalNear-black borders, 4px radius, no shadows.
dark#161a23 surfaces, #7c8cff accent, light text, dark-native pickers.
glassTranslucent white, blurred surfaces, works over imagery.

Tokens

Typography & geometry

TokenDefault
--zs-font-familyinherit
--zs-font-size0.9375rem
--zs-line-height1.4
--zs-label-size0.8125rem
--zs-height44px
--zs-radius10px
--zs-chip-radius8px
--zs-border-width1px
--zs-padding-x / --zs-padding-y12px / 5px
--zs-gap6px
--zs-dropdown-radius / --zs-dropdown-border-width12px / 1px
--zs-option-radius8px
--zs-option-padding-y / --zs-option-padding-x9px / 12px

Colour

TokenDefaultUsed by
--zs-bg#ffffffcontrol, input shell, cards
--zs-text#16181dlabels, values, options
--zs-text-muted#6b7280hints, counters, clear buttons
--zs-placeholder#9aa1acplaceholders
--zs-border-color#dfe3e8idle borders
--zs-border-color-hover#c3c9d2hover
--zs-border-color-focus#4f6bedfocus
--zs-border-color-invalid / --zs-border-color-valid#dc3545 / #198754validation
--zs-primary / --zs-primary-contrast#4f6bed / #fffchecked, focus, accents
--zs-primary-soft#eef1fdcard checked, hover wash
--zs-focus-ring / --zs-focus-ring-widthrgba(79,107,237,.22) / 3pxfocus ring
--zs-chip-bg / -text / -border#eef1fd / #33407a / #dfe5fbtags
--zs-dropdown-bg / -border / -shadowwhite / #e6e9ee / layered shadowlistbox
--zs-option-hover-bg / -active-bg / -active-textgreys/indigolistbox options
--zs-option-selected-bg / -selected-textindigo tintsselected options
--zs-group-text#8b93a1listbox groups

Field tokens

TokenDefault
--zs-check-size20px
--zs-check-radius6px
--zs-check-gap10px
--zs-check-bg / --zs-check-border#fff / #c3c9d2
--zs-check-mark#fff
--zs-check-checked-bg / -checked-border#4f6bed / #4f6bed
--zs-switch-width / -height40px / 22px
--zs-switch-off / --zs-switch-knob#d6dae1 / #fff
--zs-radio-size18px
--zs-radio-border / --zs-radio-gap#c3c9d2 / 10px
--zs-file-drop-bg / --zs-file-drop-border#f8f9fc / #cfd5de
--zs-file-thumb-bg / -text#eef1fd / #4a5590
--zs-field-gap6px

Input icons, stepper, phone, range & upload

TokenDefaultUsed by
--zs-icon-color / --zs-icon-hover-bgmuted text / primary-softinput icons, upload glyph
--zs-stepper-color / --zs-stepper-hover-bgtext / primary-soft− / + buttons
--zs-phone-borderborder colourcountry <select> separator
--zs-switch-width-lg / -height-lglarger trackmaterial/square/labeled styles
--zs-switch-on-text / --zs-switch-off-textwhite / mutedlabeled & icon switches
--zs-radius-pill999pxbutton checkbox/radio variants
--zs-avatar-size96pxavatar file variant
--zs-avatar-bg / --zs-avatar-borderprimary-soft / borderavatar target & preview fallback
--zs-range-track / --zs-range-fillborder / primarydefault & minimal range
--zs-range-gradientlinear-gradientgradient variant
--zs-range-thumb-bg / -thumb-borderwhite / primaryrange thumbs
--zs-range-tick / --zs-range-tick-textborder / mutedtick marks and labels
--zs-range-bubble-bg / -bubble-texttext / whitevalue bubble
--zs-upload-track / --zs-upload-bar / --zs-upload-successborder / primary / greenprogress bar and states

Variant hooks

Variants are selected per control and can be restyled with attribute selectors — no JS:

/* checkbox pill */
.zs-field[data-zs-variant="button"] .zs-check { --zs-pill-bg: #ecfdf3; }
/* radio tiles */
.zs-radio-group[data-zs-variant="tile"] .zs-radio { border-radius: 14px; }
/* switch skins */
.zs-field[data-zs-switch-style="ios"] .zs-switch-track::after { box-shadow: 0 1px 3px rgba(0,0,0,.3); }
/* file variants */
.zs-field[data-zs-file-variant="avatar"] { --zs-avatar-size: 128px; }
.zs-field[data-zs-file-variant="gallery"] .zs-file-list { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
/* range skins */
.zs-range[data-zs-range="gradient"] { --zs-range-gradient: linear-gradient(90deg, #22c55e, #eab308); }

data-zs-file-variant is set on the field root; the drop target also carries zs-file-drop--<variant>. data-zs-range is set on .zs-range, and validation-driven icons/progress are keyed off [data-zs-validation] and data-zs-upload-state.

Scrollbar

--zs-scrollbar-size, --zs-scrollbar-thumb, --zs-scrollbar-thumb-hover, --zs-scrollbar-thumb-reveal (hover variant), --zs-scrollbar-track.

Custom theme

.my-brand {
  --zs-primary: #e11d48;
  --zs-primary-soft: #fff1f4;
  --zs-border-color-focus: #e11d48;
  --zs-focus-ring: rgba(225, 29, 72, 0.22);
  --zs-check-checked-bg: #e11d48;
  --zs-check-checked-border: #e11d48;
  --zs-radius: 14px;
  --zs-dropdown-radius: 16px;
}
<form class="my-brand">…</form>

No JS change is needed when the tokens apply to a wrapper class. For a named preset that also works with data-zs-theme="brand" and setTheme('brand'), register the name first:

ZidanForm.themes.push('brand');   // register before fields initialise
<form data-zs-theme="brand">…</form>
[data-zs-theme="brand"] { /* tokens */ }

ZidanForm.themes is the live list the plugin validates against, so a pushed name survives initialisation and is written to the field root as data-zs-theme. Names that were never registered fall back to default; pushing after fields exist only affects setTheme() calls made afterwards.

Automatic dark mode

Add the attribute based on prefers-color-scheme:

<script>
  if (matchMedia('(prefers-color-scheme: dark)').matches) {
    document.documentElement.setAttribute('data-zs-theme', 'dark');
  }
</script>

Or scope it to a wrapper and switch at runtime:

document.querySelectorAll('.zs-field').forEach(el => el.setAttribute('data-zs-theme', 'dark'));

setTheme() on an instance does the same for one field.

Select layouts

LayoutNotes
classic-clean10px radius, standard height, soft dropdown shadow.
floating-labelLabel starts as placeholder, lifts on focus/value.
soft-pillPill trigger and chips, tinted surface.
bordered-brutalist2px black border, zero radius, offset shadow, yellow accent.
glass-elevatedBlur, translucency, elevated shadows, solid fallback without backdrop-filter.

Field layouts

LayoutNotes
stackedLabel, control, hint vertically.
inlineLabel and control on one row.
compact34px control height, smaller label.
floatingLabel lives inside the shell and lifts when filled/focused.
outlinedLike floating, with the label notching the border.
cardAdds a padded card surface around the field.

grid is not a field layout value — the grid lives on the wrapper:

<div class="zs-form-grid">
  <input data-zidan="input" data-zidan-label="First name">
  <input data-zidan="input" data-zidan-label="Last name">
  <textarea data-zidan="textarea" data-zidan-label="Notes" class="zs-full"></textarea>
</div>

--zs-grid-min / --zs-grid-gap control the auto-fit columns.

Framework adapters

data-zs-framework (or the framework option) accepts none, vanilla, bootstrap, tailwind, bulma, foundation. Adapters only remap tokens plus a few structural compat rules (Bootstrap input-group, for example). Nothing depends on the framework's JavaScript.

<html data-zs-framework="bootstrap">   <!-- whole page -->
<form data-zs-framework="tailwind">    <!-- one form -->

Scrollbar variants

<select data-zidan-select="combobox" data-zidan-scrollbar="fancy">
ValueChromium / SafariFirefox
default8px rounded thumbthin native gutter, scrollbar-color
thin6pxthin native
fancygradient thumb on tinted trackflat accent thumb (no gradients possible)
hoverinvisible until hover/focus, soft 0.3 then 0.45 on the thumbsoft 0.3 on listbox hover only
hiddenno visible bar, still scrollablescrollbar-width: none

Reduced motion & forced colours

Both are handled in the stylesheets. Keep animations in custom themes behind @media (prefers-reduced-motion: no-preference).

Markdown source: docs/theming.md. Generated by scripts/docs.mjs — edit the Markdown, not this page.