Skip to content

Commit

Permalink
add closeButtonTitle to modal header
Browse files Browse the repository at this point in the history
  • Loading branch information
Barsnes committed Aug 5, 2024
1 parent bbd0f46 commit 8c42546
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions packages/react/src/components/Modal/ModalHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ export type ModalHeaderProps = {
* @default true
*/
closeButton?: boolean;
/**
* The title of the close button.
* @default 'close modal'
*/
closeButtonTitle?: string;
/**
* The subtitle of the modal.
*/
subtitle?: string;
/**
* Change the default rendered element for the one passed as a child, merging their props and behavior.
Expand All @@ -25,7 +33,15 @@ export type ModalHeaderProps = {

export const ModalHeader = forwardRef<HTMLDivElement, ModalHeaderProps>(
(
{ closeButton = true, children, subtitle, asChild, className, ...rest },
{
closeButton = true,
closeButtonTitle = 'close modal',
children,
subtitle,
asChild,
className,
...rest
},
ref,
) => {
const Component = asChild ? Slot : 'div';
Expand Down Expand Up @@ -60,8 +76,9 @@ export const ModalHeader = forwardRef<HTMLDivElement, ModalHeaderProps>(
autoFocus
icon={true}
className='ds-modal__header__button'
title={closeButtonTitle}
>
<XMarkIcon title='close modal' fontSize='1.5em' />
<XMarkIcon title={closeButtonTitle} fontSize='1.5em' />
</Button>
)}
</Component>
Expand Down

0 comments on commit 8c42546

Please sign in to comment.