···5454 `ghost`. Never plain `default` for unselected — that reads as the hovered state.
5555-->
5656<Story name="Tab Switcher">
5757- <ButtonGroup>
5858- <Button {...segmentProps(true)}>Open</Button>
5959- <Button {...segmentProps(false)}>Closed</Button>
6060- </ButtonGroup>
5757+ <div class="flex flex-col items-start gap-4">
5858+ <ButtonGroup>
5959+ <Button {...segmentProps(true)}>Open</Button>
6060+ <Button {...segmentProps(false)}>Closed</Button>
6161+ </ButtonGroup>
6262+ <!-- selected in the middle: hovering either neighbour used to rub out the border on the
6363+ edge they share, so this is the case to check when touching the group's layering -->
6464+ <ButtonGroup>
6565+ <Button {...segmentProps(false)}>All</Button>
6666+ <Button {...segmentProps(true)}>Push</Button>
6767+ <Button {...segmentProps(false)}>Pull request</Button>
6868+ </ButtonGroup>
6969+ </div>
6170</Story>
···88 spaced: {
99 true: "gap-2",
1010 false: [
1111- "items-stretch gap-0 rounded-sm overflow-hidden border border-border-default bg-background-subtle dark:bg-background-canvas",
1111+ "items-stretch gap-0 overflow-hidden rounded-sm border border-border-default bg-background-subtle dark:bg-background-canvas",
1212 "*:relative *:border-y-0",
1313 "[&>*:first-child]:-ml-px [&>*:last-child]:-mr-px",
1414 "[&>*:not(:first-child)]:-ml-px [&>*:not(:first-child)]:[--btn-radius-l:0px]",
1515 "[&>*:not(:last-child)]:[--btn-radius-r:0px]",
1616- "[&>*:focus-visible]:z-10 [&>*:hover]:z-10"
1616+ // children overlap by 1px so adjacent borders collapse into a single seam, which
1717+ // also means a child's fill paints into its neighbour's border column. ghost
1818+ // segments have a transparent border and nothing to repaint there, so every
1919+ // bordered child has to sit above them — otherwise hovering a ghost rubs out the
2020+ // selected segment's border on whichever edge they share.
2121+ "[&>*:not([data-variant=ghost])]:z-10",
2222+ // the group clips overflow, so an outward focus ring gets cut off at its edges and
2323+ // by bordered neighbours. draw it inside the child instead.
2424+ "[&>*:focus-visible]:-outline-offset-2"
1725 ]
1826 }
1927 },