Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hiui-popper

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hiui-popper

基础弹层组件

  • 0.0.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Popper

基础弹层组件

快速使用

依附元素

import Popper from "@hi-ui/hiui/es/popper"
import React, { useState, useRef } from "react"
const demo = () => {
  const PopperAttachEle = useRef()
  const [showPopper, setShowPopper] = useState(false)
  return (
    <div>
      <div ref={PopperAttachEle}>popper-attachEle</div>
      <Popper
        // 弹出层的显示隐藏
        show={showPopper}
        // 依附的元素
        attachEle={PopperAttachEle.current}
        // 点击弹出层以及依附元素以外的区域时会触发该回调
        onClickOutside={() => {
          setShowPopper(false)
        }}
      >
        <div className='popper-content'>Popper Content</div>
      </Popper>
    </div>
  )
}

无依附元素

import Popper from "@hi-ui/hiui/es/popper"
import React, { useState, useRef } from react
const demo = () => {
  const [showPopper, setShowPopper] = useState(false)
  return (
    <div>
      <Popper
        // 弹出层的显示隐藏
        show={showPopper}
        left={20}
        top={20}
        // 点击弹出层以及依附元素以外的区域时会触发该回调
        onClickOutside={() => {
          setShowPopper(false)
        }}
      >
        <div className="popper-content">Popper Content</div>
      </Popper>
    </div>
  )
}

Props

参数说明类型可选值默认值
show弹出层显示隐藏boolean-false
attachEle依附元素,会自动显示到该元素下方,并跟随自动HTMLElement--
container弹出层依赖定位的元素,也就是弹出层参考定位的元素HTMLElement--
width弹层宽度,如果存在attachEle参数且宽度未传入的情况下,会根据attachEle的宽度进行计算,其他情况请传入宽度number | string | bool--
topGap距离依附元素的上偏移量,存在 attachEle 属性时有效,number00
leftGap距离依附元素的左偏移量,存在 attachEle 属性时有效,number00
zIndex堆叠顺序number-1060
placement位于依附元素的方位stringbottom | bottom-start | bottom-end | top | top-start | top-end | left | left-start | left-end | right | right-start | right-end | top-bottom-start(使用该属性会自动根据依附元素距离可视区域自动翻转) | top-bottom | left-right | left-right-startbottom-start

Events

参数说明类型可选值默认值
onClickOutside点击该元素外的回调方法function--
setOverlayContainer如遇到菜单滚动定位问题,试试修改为滚动的区域,并相对其定位 (3.0 新增)function(triggerNode)-() => document.body

FAQs

Package last updated on 26 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc