Skip to content

Commit

Permalink
feat(Dialog) add className prop (#5115)
Browse files Browse the repository at this point in the history
* add className prop to Dialog component

* add changeset and remove accidental classname

* add prop to docs.json
  • Loading branch information
randall-krauskopf authored Oct 15, 2024
1 parent a78ed77 commit e94f0a1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
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

0 comments on commit e94f0a1

Please sign in to comment.