Fix ToggleSwitch knob spacing and border-radius to match primer/react - #4107
Merged
Conversation
The knob now sits inset 1px from the track edges and uses a border-radius that accounts for the track border, matching the ToggleKnob styles in primer/react. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🦋 Changeset detectedLatest commit: 625dfcf The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
dylanatsmith
force-pushed
the
dats/fix-toggleswitch-knob-styling
branch
from
June 23, 2026 16:36
1bb7ddf to
f4cac1b
Compare
dylanatsmith
marked this pull request as ready for review
June 23, 2026 16:48
Contributor
There was a problem hiding this comment.
Pull request overview
Aligns the ToggleSwitch knob styling in @primer/view-components with the primer/react ToggleSwitch knob, primarily to better match spacing within the track border and the knob’s corner treatment.
Changes:
- Adjusts the checked-state knob translate and updates knob positioning to be inset from the track edges.
- Updates knob
border-radiuscalculation and removes knob shadow styling. - Adds a changeset for a patch release.
Show a summary per file
| File | Description |
|---|---|
| app/components/primer/alpha/toggle_switch.pcss | Updates ToggleSwitch knob spacing/translate and border-radius to better match primer/react. |
| .changeset/toggle-switch-knob-styling.md | Adds a patch changeset describing the visual alignment change. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 3
joshblack
approved these changes
Jun 23, 2026
…ties Introduce --toggleSwitch-knob-inset (the track border width) and --toggleSwitch-knob-offset (twice the inset), rooting the knob inset, checked travel, and concentric border-radius in a single source of truth. No visual change. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Collapse top/bottom/left into a single inset declaration (right kept auto), which also drops three needless primer/spacing stylelint-disable comments. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace the four-value inset shorthand with inset-block and inset-inline-start, dropping the auto filler for the inline-end edge. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
joshblack
approved these changes
Jun 23, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The
ToggleSwitchknob (the part that slides back and forth) didn't match the styling inprimer/react. This PR aligns the knob's spacing, border-radius, and shadow with react'sToggleKnob.ToggleSwitch.mp4
Changes
In
app/components/primer/alpha/toggle_switch.pcss, the.ToggleSwitch-knob:top: 0; bottom: 0); now inset 1px on all sides (top/bottom/left: 1px), so the knob sits within the track's border. The checked-state translate is updated totranslateX(calc(100% - 2px))to account for the inset.var(--borderRadius-medium)tocalc(var(--borderRadius-medium) - var(--borderWidth-thick)), matching react so the knob's corners nest correctly inside the track border.--shadow-resting-medium,--button-default-shadow-inset); react'sToggleKnobhas no shadow. The now-redundantbox-shadow: nonein the disabled state was also dropped.Source of truth:
primer/reactToggleSwitch.module.css→.ToggleKnob.Notes