Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/thin-keys-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': minor
---

Add 'className' prop to `Dialog` component
8 changes: 7 additions & 1 deletion packages/react/src/Dialog/Dialog.docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@
"name": "initialFocusRef",
"type": "React.RefObject<HTMLElement>",
"description": "Focus this element when the Dialog opens"
},
{
"name": "className",
"type": "string | undefined",
"defaultValue": "",
"description": "CSS string"
}
],
"subcomponents": []
}
}
7 changes: 7 additions & 0 deletions packages/react/src/Dialog/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ export interface DialogProps extends SxProp {
* The element to focus when the Dialog opens
*/
initialFocusRef?: React.RefObject<HTMLElement>

/**
* Additional class names to apply to the dialog
*/
className?: string
}

/**
Expand Down Expand Up @@ -409,6 +414,7 @@ const _Dialog = React.forwardRef<HTMLDivElement, React.PropsWithChildren<DialogP
returnFocusRef,
initialFocusRef,
sx,
className,
} = props
const dialogLabelId = useId()
const dialogDescriptionId = useId()
Expand Down Expand Up @@ -497,6 +503,7 @@ const _Dialog = React.forwardRef<HTMLDivElement, React.PropsWithChildren<DialogP
aria-modal
{...positionDataAttributes}
sx={sx}
className={className}
>
{header}
<ScrollableRegion aria-labelledby={dialogLabelId} className="DialogOverflowWrapper">
Expand Down
Loading