Skip to content

Repository files navigation

@rc-component/dialog

Ant Design Part of the Ant Design ecosystem.

💬 A composable dialog component for React.

NPM versionnpm downloadsbuild statusCodecovbundle sizedumi

English | 简体中文

Highlights

  • Supports controlled visibility, mask, keyboard close, and focus restoration.
  • Allows custom title, footer, close icon, container, motion, and modal content rendering.
  • Provides semantic classNames and styles hooks for the dialog structure.
  • Ships compiled JavaScript, TypeScript definitions, and CSS assets.

Install

npm install @rc-component/dialog

Usage

importDialogfrom'@rc-component/dialog';import'@rc-component/dialog/assets/index.css';exportdefaultfunctionApp(){return(<Dialogtitle="Dialog"visibleonClose={()=>{}}><p>Dialog content</p></Dialog>);}

Examples

Run the local dumi site:

npm install
npm start

Then open http://localhost:8000.

API

PropertyDescriptionTypeDefault
afterCloseCallback after close animation ends() => void-
animationDialog animation namestring-
classNameAdditional dialog class namestring-
classNamesSemantic class names{ header?: string; body?: string; footer?: string; mask?: string; content?: string; wrapper?: string }-
closableWhether to show close button, or close button propsboolean | objecttrue
closeIconCustom close iconReact.ReactNode-
destroyOnHiddenUnmount children after dialog closesbooleanfalse
focusTriggerAfterCloseFocus trigger element after closebooleantrue
footerDialog footerReact.ReactNode-
forceRenderRender dialog before it is first shownbooleanfalse
getContainerContainer where dialog is mounted() => HTMLElement-
keyboardWhether pressing Esc closes the dialogbooleantrue
maskWhether to show maskbooleantrue
maskAnimationMask animation namestring-
maskClosableWhether clicking mask closes the dialogbooleantrue
maskTransitionNameMask transition class namestring-
modalRenderCustom modal content renderer(node: React.ReactNode) => React.ReactNode-
mousePositionMouse position used for transform origin{ x: number; y: number }-
prefixClsComponent class name prefixstringrc-dialog
scrollLockWhether to lock body scroll when openbooleantrue
styleRoot dialog styleReact.CSSProperties-
stylesSemantic styles{ header?: React.CSSProperties; body?: React.CSSProperties; footer?: React.CSSProperties; mask?: React.CSSProperties; content?: React.CSSProperties; wrapper?: React.CSSProperties }-
titleDialog titleReact.ReactNode-
transitionNameDialog transition class namestring-
visibleWhether the dialog is visiblebooleanfalse
zIndexDialog z-indexnumber-
onCloseCallback when close button or mask is clicked(event: React.SyntheticEvent) => void-

Development

npm install
npm start

The dumi site runs at http://localhost:8000 by default.

npm test
npm run tsc
npm run lint
npm run compile
npm run build

Release

npm run prepublishOnly

The release flow is handled by @rc-component/np through the rc-np command after the package build.

License

@rc-component/dialog is released under the MIT license.

About

💬 A composable dialog component for React.

Topics

Resources

Stars

455 stars

Watchers

25 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages