Skip to content

[6.x] Button single variant - #19306

Merged
brandonkelly merged 20 commits into
6.xfrom
feature/button-single-variant
Jul 31, 2026
Merged

[6.x] Button single variant#19306
brandonkelly merged 20 commits into
6.xfrom
feature/button-single-variant

Conversation

@brianjhanson

Copy link
Copy Markdown
Contributor

Previously buttons has two customization axis. You could specify either a variant (accent, neutral or danger) and an appearance (solid, outline, fill, plain) to determine what your button looked like.

After revisiting (and looking at plugin kit, I feel like that's a bit overkill. This flattens appearance and variant into a single variant property which can be one of: primary, danger, danger-plain, solid, fill, outline, dashed, plain, link or none.

CleanShot 2026-07-24 at 10 23 47@2x

danger-plain is the only one that bugs me a bit, but I think that wart is better than having the ability to create buttons that may only appear once in the UI.

This also refactors the appearance=inherit property on buttons that will allow a button to take on the color of its colorable parent. That behavior is now created by specifying a single inherit value on the button.

CleanShot 2026-07-24 at 10 26 09@2x

In this mode primary and danger buttons retain their normal fill, but other buttons will try to blend in.

brianjhanson and others added 7 commits July 23, 2026 13:46
Replace the two-axis (variant + appearance) button API with one `variant`
property: primary, danger, solid, fill (default), outline, dashed, plain,
link, none. `primary`/`danger` are the colored, stable variants; the rest use
the neutral palette.

Add a boolean `inherit` property (orthogonal to variant) so neutral variants
adopt the ambient colorable palette in a [data-color]/callout context, while
primary/danger keep their own colors.

Rewrites button.styles.ts around the single axis, and updates the stories and
docs (combined the variant/appearance stories, added an Inherit demo).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adapt the package to the collapsed button API:
- index.ts stops re-exporting the removed ButtonAppearance.
- variants.styles.ts swaps the [variant='default'] block for [variant='accent']
  and [variant='neutral'] (used by callout/indicator/action-item).
- The tokens "Button Matrix" story and FilterHud now use the single variant axis
  (e.g. ButtonVariant.Fill / ButtonVariant.Primary).

Note: the broader app consumer migration (variant/appearance usages across
resources/js) is still pending and tracked separately.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
constants/colors.ts and scripts/generate-colors.js each hard-coded the color
palette and semantic map, and had drifted (info: blue vs sky, warning: orange
vs yellow; accent: red vs blue).

Introduce constants/colors.data.ts as the single source of truth. colors.ts
builds its Color map + ColorValue/ColorKey from it; generate-colors.js loads
it via esbuild (it can't import TS directly). Regenerate colorable.css — the
token output is unchanged except accent is corrected from a stale red to blue.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@brianjhanson
brianjhanson requested a review from gcamacho079 July 24, 2026 15:26
@github-actions

github-actions Bot commented Jul 24, 2026

Copy link
Copy Markdown

@brianjhanson
brianjhanson marked this pull request as ready for review July 29, 2026 16:30
@brianjhanson

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

…variant

# Conflicts:
#	packages/craftcms-ui/src/components/button/button.ts
#	resources/js/common/form/InputCombobox.vue

Co-authored-by: brianjhanson <1843073+brianjhanson@users.noreply.github.com>

Copilot AI commented Jul 29, 2026

Copy link
Copy Markdown

@copilot resolve the merge conflicts in this pull request

Resolved. Two conflicts were present:

  1. packages/craftcms-ui/src/components/button/button.ts — 6.x added visuallyHiddenStyles + variantsStyles to the styles array and an announcementTimer field. Our branch had a constructor() defaulting type = 'button', originalType for restoring type after link mode, and the variant palette styles already inlined in button.styles.ts (so no need for variantsStyles). Resolved by keeping visuallyHiddenStyles in the styles array (needed for the live region), our constructor, and both originalType and announcementTimer.

  2. resources/js/common/form/InputCombobox.vue — deleted in 6.x (consolidated into craft-combobox); accepted the deletion.

@brandonkelly
brandonkelly merged commit ffb92f6 into 6.x Jul 31, 2026
@brandonkelly
brandonkelly deleted the feature/button-single-variant branch July 31, 2026 17:20
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.

3 participants