Skip to content

fix(accordion): use z-index overlap for themed open item borders (alternative to #42092)#42661

Open
q121212 wants to merge 1 commit into
twbs:v6-devfrom
q121212:fix/accordion-open-border-colors
Open

fix(accordion): use z-index overlap for themed open item borders (alternative to #42092)#42661
q121212 wants to merge 1 commit into
twbs:v6-devfrom
q121212:fix/accordion-open-border-colors

Conversation

@q121212

@q121212 q121212 commented Jul 12, 2026

Copy link
Copy Markdown

Closes #42092

Problem

When a themed accordion item is opened, the top border appears gray instead of the theme color. This happens because the previous (closed) item retains a gray border-bottom, and the open item has no border-top (from the &:not(:first-of-type) { border-block-start: 0; } rule).

Approach (per @mdo's review suggestion)

Instead of manipulating borders with :has() and explicit border-block-start, use relative positioning on the open item:

  1. position: relative; z-index: 2 — lifts the open item above siblings
  2. margin-block-start: calc(-1 * var(--accordion-border-width)) — pulls it up by one border-width, visually overlapping the previous item's bottom border

This is simpler than PR #42092's approach:

  • No :has() dependency (better browser support)
  • Only 3 properties added
  • Naturally works with all variants (flush, always-open, theme-*)

Testing

  • npm run css-lint passes
  • npm run css builds cleanly
  • Visual: open accordion with .theme-primary shows correct colored top border
  • Visual: flush variant unchanged
  • Visual: always-open variant unchanged

@q121212 q121212 requested a review from a team as a code owner July 12, 2026 00:22
@github-project-automation github-project-automation Bot moved this to Inbox in v6.0.0 Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Inbox

Development

Successfully merging this pull request may close these issues.

2 participants