Describe the bug
When using <ToggleGroup variant="outline" spacing={0}> with Tailwind v4,
the items render as fully-separated rounded buttons instead of a segmented
control.
The conditional utilities defined inside ToggleGroupItem -
group-data-[spacing=0]/toggle-group:rounded-none,
...:first:rounded-l-md, ...:last:rounded-r-md,
...:data-[variant=outline]:border-l-0 and friends - do not win over
rounded-md coming from toggleVariants base. Result: every item shows
all four corners rounded, both inner borders are visible, and a visible
gap appears between items even when spacing={0}.
Two probable root causes:
-
CSS source order. The conditional utilities and rounded-md end up in
the same Tailwind layer with equal specificity, but rounded-md is
emitted AFTER the conditional class, so it wins at runtime even though
the conditional class is the intended override for spacing=0.
-
gap-[--spacing(var(--gap))] on the group root. Tailwind v4 does not
appear to resolve the --spacing() function inside arbitrary value
brackets when its argument comes from a CSS custom property
(var(--gap)). The declaration ends up either invalid or falling back
to a non-zero value, producing a visible gap between items.
I do not intend to submit a PR for this issue at the moment - happy to
provide the minimal repro and further diagnostics if needed.
Affected component/components
ToggleGroup
How to reproduce
-
Fresh Next.js 16 + React 19 + Tailwind v4 project (shadcn registry
new-york-v4).
-
Install ToggleGroup via the CLI:
npx shadcn@latest add toggle-group
-
Use the component with variant="outline" and explicit spacing={0}:
import {
ToggleGroup,
ToggleGroupItem,
} from "@/components/ui/toggle-group";
export default function Demo() {
return (
<ToggleGroup
type="single"
variant="outline"
spacing={0}
defaultValue="a"
>
<ToggleGroupItem value="a">A</ToggleGroupItem>
<ToggleGroupItem value="b">B</ToggleGroupItem>
<ToggleGroupItem value="c">C</ToggleGroupItem>
</ToggleGroup>
);
}
-
Render the page. Expected: segmented control, outer corners rounded,
inner corners square, single shared border between items, no gap.
Observed: every item rendered as a standalone rounded outlined button
with a visible gap between items.
-
Workaround that does render correctly (forces the segmented look via
inline styles, bypassing cn / tw-merge / Tailwind source order):
<ToggleGroupItem
value="a"
style={{
borderTopRightRadius: 0,
borderBottomRightRadius: 0,
}}
>
A
</ToggleGroupItem>
<ToggleGroupItem
value="b"
style={{
borderTopLeftRadius: 0,
borderBottomLeftRadius: 0,
borderLeftWidth: 0,
}}
>
B
</ToggleGroupItem>
Codesandbox/StackBlitz link
No response
Logs
System Info
- shadcn-ui registry: `new-york-v4` (synced ~May 2026)
- tailwindcss: 4.x
- next: 16.x
- react: 19.x
- radix-ui ToggleGroup primitive (imported from the `radix-ui` umbrella)
- node: 20.x / 22.x
- OS: macOS 26.5
- Browsers tested: Chrome (latest), Safari (latest)
Before submitting
Describe the bug
When using
<ToggleGroup variant="outline" spacing={0}>with Tailwind v4,the items render as fully-separated rounded buttons instead of a segmented
control.
The conditional utilities defined inside
ToggleGroupItem-group-data-[spacing=0]/toggle-group:rounded-none,...:first:rounded-l-md,...:last:rounded-r-md,...:data-[variant=outline]:border-l-0and friends - do not win overrounded-mdcoming fromtoggleVariantsbase. Result: every item showsall four corners rounded, both inner borders are visible, and a visible
gap appears between items even when
spacing={0}.Two probable root causes:
CSS source order. The conditional utilities and
rounded-mdend up inthe same Tailwind layer with equal specificity, but
rounded-mdisemitted AFTER the conditional class, so it wins at runtime even though
the conditional class is the intended override for
spacing=0.gap-[--spacing(var(--gap))]on the group root. Tailwind v4 does notappear to resolve the
--spacing()function inside arbitrary valuebrackets when its argument comes from a CSS custom property
(
var(--gap)). The declaration ends up either invalid or falling backto a non-zero value, producing a visible gap between items.
I do not intend to submit a PR for this issue at the moment - happy to
provide the minimal repro and further diagnostics if needed.
Affected component/components
ToggleGroup
How to reproduce
Fresh Next.js 16 + React 19 + Tailwind v4 project (shadcn registry
new-york-v4).Install ToggleGroup via the CLI:
Use the component with
variant="outline"and explicitspacing={0}:Render the page. Expected: segmented control, outer corners rounded,
inner corners square, single shared border between items, no gap.
Observed: every item rendered as a standalone rounded outlined button
with a visible gap between items.
Workaround that does render correctly (forces the segmented look via
inline styles, bypassing
cn/tw-merge/ Tailwind source order):Codesandbox/StackBlitz link
No response
Logs
System Info
Before submitting