Skip to content

Author variant tags when exporting a style#2

Open
FlorianKoerner wants to merge 1 commit into
mainfrom
feat/variant-tags
Open

Author variant tags when exporting a style#2
FlorianKoerner wants to merge 1 commit into
mainfrom
feat/variant-tags

Conversation

@FlorianKoerner

Copy link
Copy Markdown
Member

What

Adds a Tags tab to each component group so a style author can assign descriptive tags to variants (for example mood:happy or hairLength:long). The tags are written as variant.tags in the exported style definition.

Why

DiceBear core and the language ports already read variant tags to filter variants through the tags render option, but nothing could author them yet. This is the authoring side, so styles can carry the tags the filter acts on.

How

It mirrors the existing per-variant weights path end to end:

  • A tags record on ComponentGroupSettings, persisted to pluginData like weights.
  • A TagsGroup chip input, one row per variant, on a Tags tab beside Weights (definition exports only, hidden for alias groups).
  • Validation in the UI sanitizer via a shared isValidVariantTag and MAX_VARIANT_TAGS, so the export stays schema-valid: category or category:value in camelCase, up to 129 characters, at most 32 per variant, unique. There is no exclusion prefix, since that belongs to the render-option filter, not the data.
  • The export writer attaches variant.tags and omits empty arrays.

Notes

Validation lives in the UI sanitizer, the single gate before persist, matching how weights and color arrays are handled. Re-validating on the code side would duplicate the validator across the bundle boundary, so it stays a known defense-in-depth follow-up.

The generated components.d.ts is left out of this branch. It only churns a trailing semicolon on build.

A style author can now assign descriptive tags to variants from a new Tags tab in each component group, the same way per-variant weights are set. Each tag is validated against the schema grammar (category or category:value in camelCase, up to 129 characters, at most 32 per variant, unique) and written as variant.tags in the exported definition, dropped when empty.

DiceBear core and the language ports already read these tags to filter variants through the tags render option. This adds the authoring side so styles can carry the tags that filter acts on.
@FlorianKoerner FlorianKoerner self-assigned this Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant