npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@rainbow_deer/dialog

v0.1.13

Published

React component.

Readme

Dialog

install

npm install @rainbow_deer/dialog
yarn add @rainbow_deer/dialog

usage

basic

import React, { useState } from 'react'
import Dialog from '@rainbow_deer/dialog'
import Button from '@rainbow_deer/button'

export default () => {
  const [visible, setVisible] = useState(false)
  const handleClick = () => {
    setVisible(true)
  }
  return (
    <>
      <Button onClick={handleClick}>打开</Button>
      <Dialog onClose={() => setVisible(false)} visible={visible} title='标题'>
        body
      </Dialog>
    </>
  )
}

drag

import React, { useState } from 'react'
import Dialog from '@rainbow_deer/dialog'
import Button from '@rainbow_deer/button'

export default () => {
  const [visible, setVisible] = useState(false)
  const handleClick = () => {
    setVisible(true)
  }
  return (
    <>
      <Button onClick={handleClick}>打开</Button>
      <Dialog.DialogDrag onClose={() => setVisible(false)} visible={visible} title='标题'>
        body
      </Dialog.DialogDrag>
    </>
  )
}

custom dialog

import React, { useState } from 'react'
import Dialog from '@rainbow_deer/dialog'
import Button from '@rainbow_deer/button'

export default () => {
  const [visible, setVisible] = React.useState(false)
  return (
    <>
      <Button onClick={() => setVisible(true)}>打开</Button>
      <Dialog
        title={'标题'}
        visible={visible}
        onClose={() => setVisible(false)}
        dialogRender={() => (
          <div
            style={{ border: '1px solid #ccc', padding: 20, borderRadius: 4, background: '#fff' }}
          >
            <h3>标题</h3>
            <div>body</div>
            <div style={{ textAlign: 'right' }}>
              <button style={{ marginRight: 8 }} onClick={() => setVisible(false)}>
                取消
              </button>
              <button>确定</button>
            </div>
          </div>
        )}
      ></Dialog>
    </>
  )
}

custom footer

import React, { useState } from 'react'
import Dialog from '@rainbow_deer/dialog'
import Button from '@rainbow_deer/button'

export default () => {
  const [visible, setVisible] = React.useState(false)
  return (
    <>
      <Button type='emphasize' onClick={() => setVisible(true)}>
        打开
      </Button>
      <Dialog
        title='标题'
        visible={visible}
        onClose={() => setVisible(false)}
        footer={[<div>自定义页脚</div>]}
      >
        body
      </Dialog>
    </>
  )
}

dialog confirm

import React, { useState } from 'react'
import Dialog from '@rainbow_deer/dialog'
import Button from '@rainbow_deer/button'
export default () => {
  const handleClick = () => {
    const destroy = Dialog.confirm({
      title: '标题',
      onOk: () => {
        destroy()
      },
      onClose: () => {
        destroy()
      },
    })
  }
  return <Button onClick={handleClick}>打开</Button>
}

props

interface DialogWrapProps {
  /**
   * 显示隐藏
   */
  visible: boolean
  /**
   * 作用于dialog className
   */
  className?: string
  /**
   * 宽
   */
  width?: number
  /**
   * 高
   */
  height?: number
  /**
   * dialog 样式
   */
  style?: React.CSSProperties
  /**
   * body样式
   */
  bodyStyle?: React.CSSProperties
  /**
   * 页脚样式
   */
  footerStyle?: React.CSSProperties
  /**
   * 页脚类选择器
   */
  footerClassName?: string
  /**
   *  类选择器 前缀
   */
  prefixCls?: string
  /**
   *  层级
   */
  zIndex?: number
  /**
   *  自定义关闭图标
   */
  closeIcon?: React.ReactNode
  /**
   *  是否支持esc 关闭dialog
   */
  keyboard?: boolean
  /**
   *  标题
   */
  title?: any
  /**
   *  页脚
   */
  footer?: React.ReactNode[]
  /**
   *  是否强制渲染
   */
  forceRender?: boolean
  /**
   * 确认文本
   */
  okText?: string
  /**
   * 关闭文本
   */
  closeText?: string
  /**
   *  关闭
   */
  onClose?: () => void
  /**
   *  确认
   */
  onOk?: () => void
  /**
   * 确定按钮 loading
   */
  confirmLoading?: boolean
  /**
   *  关闭销毁组件
   */
  destroyOnClose?: boolean
  /**
   * 关闭后回调
   */
  onAfterClose?: () => void
  /**
   * 渲染父级
   */
  getContainer?: () => HTMLElement
  /**
   *  自定义dialog
   */
  dialogRender?: (content: React.ReactElement) => React.ReactElement
  /**
   * 是否开启动画
   */
  openAnimation?: boolean
  /**
   * 动画
   */
  animationName?: string
  /**
   * 遮罩层动画
   */
  maskAnimationName?: string
  /**
   *  动画周期
   */
  animationDuration?: number
  /**
   *  是否显示关闭
   */
  closable?: boolean
  /**
   *  是否显示遮罩
   */
  mask?: boolean
  /**
   *  遮罩样式
   */
  maskStyle?: React.CSSProperties
  children: React.ReactNode
}