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
1 change: 1 addition & 0 deletions packages/core/src/components/dialog/_dialog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ $dialog-header-padding: $pt-spacing;
.#{$ns}-heading {
@include overflow-ellipsis;
flex: 1 1 auto;
font-size: 14px;
line-height: inherit;
margin: 0;

Expand Down
14 changes: 11 additions & 3 deletions packages/core/src/components/dialog/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
import * as Errors from "../../common/errors";
import { uniqueId } from "../../common/utils";
import { Button } from "../button/buttons";
import { H6 } from "../html/html";
import { H2 } from "../html/html";
import { Icon } from "../icon/icon";
import type { BackdropProps, OverlayableProps } from "../overlay/overlayProps";
import { Overlay2 } from "../overlay2/overlay2";
Expand Down Expand Up @@ -83,6 +83,13 @@ export interface DialogProps extends OverlayableProps, BackdropProps, Props {
*/
title?: React.ReactNode;

/**
* HTML heading component to use for the dialog title.
*
* @default H2
*/
titleTagName?: React.ElementType<React.HTMLAttributes<HTMLElement>>;

/**
* Name of the transition for internal `CSSTransition`. Providing your own
* name here will require defining new CSS transition properties.
Expand Down Expand Up @@ -117,6 +124,7 @@ export class Dialog extends AbstractPureComponent<DialogProps> {
public static defaultProps: DialogProps = {
canOutsideClickClose: true,
isOpen: false,
titleTagName: H2,
};

private childRef = createRef<HTMLDivElement>();
Expand Down Expand Up @@ -189,14 +197,14 @@ export class Dialog extends AbstractPureComponent<DialogProps> {
}

private maybeRenderHeader() {
const { icon, title } = this.props;
const { icon, title, titleTagName: TitleTagName = H2 } = this.props;
if (title == null) {
return undefined;
}
return (
<div className={Classes.DIALOG_HEADER}>
<Icon icon={icon} size={IconSize.STANDARD} aria-hidden={true} tabIndex={-1} />
<H6 id={this.titleId}>{title}</H6>
<TitleTagName id={this.titleId}>{title}</TitleTagName>
{this.maybeRenderCloseButton()}
</div>
);
Expand Down