Skip to content

Commit e94f0a1

Browse files
feat(Dialog) add className prop (#5115)
* add className prop to Dialog component * add changeset and remove accidental classname * add prop to docs.json
1 parent a78ed77 commit e94f0a1

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

.changeset/thin-keys-move.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react': minor
3+
---
4+
5+
Add 'className' prop to `Dialog` component

packages/react/src/Dialog/Dialog.docs.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,13 @@
6464
"name": "initialFocusRef",
6565
"type": "React.RefObject<HTMLElement>",
6666
"description": "Focus this element when the Dialog opens"
67+
},
68+
{
69+
"name": "className",
70+
"type": "string | undefined",
71+
"defaultValue": "",
72+
"description": "CSS string"
6773
}
6874
],
6975
"subcomponents": []
70-
}
76+
}

packages/react/src/Dialog/Dialog.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ export interface DialogProps extends SxProp {
142142
* The element to focus when the Dialog opens
143143
*/
144144
initialFocusRef?: React.RefObject<HTMLElement>
145+
146+
/**
147+
* Additional class names to apply to the dialog
148+
*/
149+
className?: string
145150
}
146151

147152
/**
@@ -409,6 +414,7 @@ const _Dialog = React.forwardRef<HTMLDivElement, React.PropsWithChildren<DialogP
409414
returnFocusRef,
410415
initialFocusRef,
411416
sx,
417+
className,
412418
} = props
413419
const dialogLabelId = useId()
414420
const dialogDescriptionId = useId()
@@ -497,6 +503,7 @@ const _Dialog = React.forwardRef<HTMLDivElement, React.PropsWithChildren<DialogP
497503
aria-modal
498504
{...positionDataAttributes}
499505
sx={sx}
506+
className={className}
500507
>
501508
{header}
502509
<ScrollableRegion aria-labelledby={dialogLabelId} className="DialogOverflowWrapper">

0 commit comments

Comments
 (0)