Skip to content

feat(ui): add an unstyled Toggle and ToggleGroup variant - #858

Draft
bntvllnt wants to merge 4 commits into
mainfrom
feat/toggle-unstyled-v2
Draft

bntvllnt wants to merge 4 commits into
mainfrom
feat/toggle-unstyled-v2

Conversation

@bntvllnt

@bntvllnt bntvllnt commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

Fixes #749

Supersedes #755. The owner can close #755 once this lands; this PR leaves it open.

Why a new branch: #755 was stacked on #720 and carried #720's 45 commits. #720 was squash-merged, so a merge of main into #755 would replay that history as conflicts. This branch starts from main and re-applies only #755's own three commits (resolved onto main's current toggle.tsx and toggle-group.tsx, which now use named(...) and UnstyledToggleGroup).

Summary

  • New: Toggle, ToggleGroup and ToggleGroupItem take variant="unstyled".
    • It keeps the toggle behaviour: pressed state, aria-pressed / aria-checked, roles, group arrow-key focus, disabled, asChild and ref.
    • It adds no classes of its own: the group drops flex items-center justify-center gap-1, and items drop the toggle classes. size has no effect.
    • With no className, an unstyled part renders no class attribute.
  • Why: a segmented control or chip row with its own look can reuse the toggle behaviour without overriding classes one by one.
  • Unchanged: every other variant and size renders the same class string as before, including the forced-colors classes main added since feat(ui): add an unstyled Toggle and ToggleGroup variant #755. toggleVariants(null) still returns the default classes, as cva did.

How it works

  • toggle.tsx: the cva call becomes styledToggleVariants. toggleVariants wraps it with the same call shape and returns only the caller's classes for "unstyled" (the pattern Button uses).
  • toggle-group.tsx: the group skips its layout classes when variant === "unstyled". Items take the group's variant through context, so the group's variant wins over an item's (the mdx says so).

Fits main

  • No new imports or runtime dependencies, no Radix, ui-sdk pin untouched. Additive: variant gains one value.
  • No exit-animation or token changes.

Size

Pending: the * (every export, up front) delta against main is measured with the local gates, which wait for a load < 12 slot on the shared build box.

Expected visual changes (for the owner, Visual Diff)

  • New stories: Toggle › VariantUnstyled, ToggleGroup › Unstyled.
  • No change expected to any existing story.

The visual-change-approved label is the owner's call; it was not applied here.

Test plan

Pending: local gates are queued (load gate). This PR stays a draft until they all pass.

Type of change

  • feat: new API

Breaking changes

None. variant gains one value.

Checklist

  • Follows AGENTS.md conventions.
  • Tests added; they fail on main's sources (see Test plan).
  • CHANGELOG under [Unreleased] › Added.
  • toggle.mdx and toggle-group.mdx updated.
  • No any, as, @ts-ignore or eslint-disable added.

Re-applies #755 on current main: variant="unstyled" on Toggle, ToggleGroup and ToggleGroupItem keeps the toggle behaviour and adds no classes of its own.
@vllnt-public-apps

vllnt-public-apps Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

The preview deployment for registry is ready. 🟢

Open Preview | Open Build Logs | Open Application Logs

Last updated at: 2026-12-03 20:23:53 CET

@vllnt-public-apps

vllnt-public-apps Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

The preview deployment for storybook is ready. 🟢

Open Preview | Open Build Logs | Open Application Logs

Last updated at: 2026-12-03 20:20:40 CET

This branch has not been deployed

No deployments
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.

[feat] Unstyled Toggle and ToggleGroup variant

1 participant