Add align prop to Dialog component#7594
Conversation
🦋 Changeset detectedLatest commit: 5ee2809 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: francinelucca <40550942+francinelucca@users.noreply.github.com>
verticalPosition prop to Dialog component
|
|
@copilot ensure consumers are able to override the amount of padding through a supplied Dialog classname, which means you should put the margin inside the dialog, not the backdrop. Also data-position-narrow should not override the align-items prop if a verticalPosition is set |
… in narrow breakpoint Co-authored-by: francinelucca <40550942+francinelucca@users.noreply.github.com>
Done in b2aa8eb. Two changes made to
|
|
@copilot rename new prop to "align" |
Co-authored-by: francinelucca <40550942+francinelucca@users.noreply.github.com>
Done in 8041645. Renamed |
verticalPosition prop to Dialog componentalign prop to Dialog component
|
👋 Hi from github/github-ui! Your integration PR is ready: https://github.com/github/github-ui/pull/15020 |
Closes https://github.com/github/primer/issues/6439
Dialog only controlled horizontal positioning. Developers needing vertical control resorted to CSS hacks using
:has()pseudo-selectors on the backdrop. This adds a first-classalignprop that works whenpositionis"center"(the default).Changelog
New
alignprop onDialog:'top' | 'center' | 'bottom'— controls vertical alignment of the dialog within the viewport whenpositionis"center"(the default). The default offset margin (var(--base-size-64)) is applied on the dialog element itself and can be overridden via a consumer-suppliedclassName.Changed
Dialog.module.css—data-alignmargin rules are scoped inside the[data-position-regular='center']block so they only apply whenpositionis"center". Non-center positions (left,right) take precedence andalignhas no visual effect. At narrow breakpoints,alignoverrides are allowed only whendata-position-narrow='center';bottomandfullscreennarrow positions have noaligneffect — both the backdropalign-itemsand dialog margins are unaffected. CSS specificity is correctly ordered throughout: backdropalignrules use:where()to zero out:not()specificity so narrow-position rules always win by source order; dialog margin reset rules forbottom/fullscreencompile to higher specificity than the margin-setting rule.Removed
AlignTopWithHorizontalPositionstory — removed becausealigndoes not apply whenpositionis non-center.Rollout strategy
Testing & Reviewing
Two Storybook stories cover top and bottom alignment (with default center position). Unit tests assert correct
data-alignattribute on both dialog and backdrop elements. VRT covers top and bottom variants across themes.Usage:
Omitting
alignleaves existing behavior unchanged (centered). Specifying a non-centerposition("left","right") or a narrow position of"bottom"or"fullscreen"causesalignto have no visual effect on either the backdrop or the dialog element.Merge checklist
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.