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

@chakra-ui/popper

Package Overview
Dependencies
Maintainers
3
Versions
160
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chakra-ui/popper - npm Package Compare versions

Comparing version 3.0.3 to 3.0.4

dist/index.cjs.js

17

package.json
{
"name": "@chakra-ui/popper",
"version": "3.0.3",
"version": "3.0.4",
"description": "A React component and hooks wrapper for popper.js",

@@ -21,4 +21,4 @@ "keywords": [

"license": "MIT",
"main": "dist/index.js",
"module": "dist/index.mjs",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
"types": "dist/index.d.ts",

@@ -40,3 +40,3 @@ "files": [

"dependencies": {
"@chakra-ui/react-utils": "2.0.2",
"@chakra-ui/react-utils": "2.0.3",
"@popperjs/core": "^2.9.3"

@@ -48,3 +48,3 @@ },

"devDependencies": {
"@chakra-ui/hooks": "2.0.5",
"@chakra-ui/hooks": "2.0.6",
"framer-motion": "^6.2.9",

@@ -54,8 +54,9 @@ "react": "^18.0.0"

"scripts": {
"build": "tsup src/index.ts --format=esm,cjs --dts",
"build": "tsup src/index.ts --dts",
"dev": "pnpm build -- --watch",
"clean": "rimraf dist .turbo",
"typecheck": "tsc --noEmit",
"build:fast": "tsup src/index.ts --format=esm,cjs"
}
"build:fast": "tsup src/index.ts"
},
"readme": "# Popper\n\nA React hooks wrapper for popper.js to dynamic positioning of containers around\na reference.\n\n> This is an internal hook of Chakra-UI, and it's not covered by semver, and may\n> cause unexpected or broken application behavior. Use them at your own risk.\n\n## Installation\n\n```sh\nyarn add @chakra-ui/popper\n```\n\n## Basic usage\n\nBy default, the `usePopper` hook returns props for the popper, reference and\narrow.\n\n```jsx\nimport { Box } from \"@chakra-ui/layout\"\nimport { Button } from \"@chakra-ui/button\"\nimport { useDisclosure } from \"@chakra-ui/hooks\"\nimport { usePopper } from \"@chakra-ui/popper\"\n\nfunction Example() {\n const { isOpen, onToggle } = useDisclosure()\n const { popperRef, referenceRef, getArrowProps } = usePopper()\n return (\n <>\n <Button ref={referenceRef} onClick={onToggle} mb={2}>\n {isOpen ? \"Click me to see less\" : \"Click me to see more\"}\n </Button>\n {isOpen && (\n <Box ref={popperRef} bg=\"red\">\n <div\n {...getArrowProps({\n style: {\n background: \"red\",\n },\n })}\n />\n This is a popover for the button!\n </Box>\n )}\n </>\n )\n}\n```\n\n## Parameters\n\n### Changing the placement\n\nYou can change the placement of the popper by passing the `placement` option to\n`usePopper` and set it to the `popper.js` placement.\n\n```jsx\nconst { popperRef, referenceRef } = usePopper({\n placement: \"right-start\",\n})\n```\n\n### Match reference's width\n\nIn some cases, you might want to allow the popper take the width of the\nreference. For example, autocomplete, select, etc.\n\nTo achieve this, pass the `matchWidth` option and set it to `true`\n\n```jsx\nconst { popperRef, referenceRef } = usePopper({\n matchWidth: true,\n})\n```\n\n### Place the popper next to the reference\n\nYou can place the popper next to the reference without margin or distance\nbetween them. Useful to create an autocomplete or typeahead feature.\n\n```jsx\nconst { popperRef, referenceRef } = usePopper({\n gutter: 0,\n})\n```\n\n### Using inside a fixed container\n\nIf the reference element is inside a fixed container, you should use the `fixed`\nstrategy.\n\n```jsx\nconst { popperRef, referenceRef } = usePopper({\n strategy: \"fixed\",\n})\n```\n\n## Adding transition\n\nWhen add transitions to a popper component, it is usually advised to apply\npopper and transition to different elements.\n\n```tsx\n// 1. Import components\nimport { useDisclosure } from \"@chakra-ui/hooks\"\nimport { usePopper } from \"@chakra-ui/popper\"\nimport { motion, AnimatePresence, Variants } from \"framer-motion\"\n\nexport function Example() {\n // 2. Create toggle state\n const { isOpen, onToggle } = useDisclosure()\n\n // 3. Create motion variants\n const slide: Variants = {\n exit: {\n y: -2,\n opacity: 0,\n },\n enter: {\n y: 0,\n opacity: 1,\n },\n }\n\n // 4. Consume the `usePopper` hook\n const { getPopperProps, getReferenceProps, getArrowProps, transformOrigin } =\n usePopper({\n placement: \"bottom-start\",\n })\n\n return (\n <>\n <button {...getReferenceProps({ onClick: onToggle })}>Toggle</button>\n <div {...getPopperProps()}>\n <AnimatePresence>\n {isOpen && (\n <motion.div\n transition={{\n type: \"spring\",\n duration: 0.2,\n }}\n variants={slide}\n initial=\"exit\"\n animate=\"enter\"\n exit=\"exit\"\n style={{\n background: \"red\",\n width: 200,\n transformOrigin,\n borderRadius: 4,\n }}\n >\n Testing\n <div\n {...getArrowProps({\n style: {\n background: \"red\",\n },\n })}\n />\n </motion.div>\n )}\n </AnimatePresence>\n </div>\n </>\n )\n}\n```\n\n> When not rendering the popper conditionally, we recommend using\n> `visibility: hidden` instead of `hidden` or `display: none`\n"
}
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