Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 400eceb

Browse files
ragurneyFezVrasta
authored andcommitted
docs: refactor render prop descriptions and add detail about arrow styles (#292)
1 parent 45d78d9 commit 400eceb

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

README.md

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
React wrapper around [Popper.js](https://popper.js.org).
1111

12-
**important note:** popper.js is **not** a tooltip library, it's a *positioning engine* to be used to build features such as (but not restricted to) tooltips.
12+
**important note:** popper.js is **not** a tooltip library, it's a _positioning engine_ to be used to build features such as (but not restricted to) tooltips.
1313

1414
## Install
1515

@@ -61,8 +61,8 @@ const Example = () => (
6161
familiar with it, please read more [on the official React documentation](https://reactjs.org/docs/render-props.html).
6262

6363
> Using React <=15 or Preact? The components created with them don't support to return
64-
[fragments](https://reactjs.org/docs/fragments.html), this means that you will need to
65-
wrap `<Reference />` and `<Popper />` into a single, common, `<div />` to make `react-popper` work.
64+
> [fragments](https://reactjs.org/docs/fragments.html), this means that you will need to
65+
> wrap `<Reference />` and `<Popper />` into a single, common, `<div />` to make `react-popper` work.
6666
6767
### API documentation
6868

@@ -99,27 +99,21 @@ children: ({|
9999
|}) => Node
100100
```
101101
102-
A function (render prop) that takes as argument an object containing the properties
103-
`ref`, `style`, `placement`, and`arrowProps`.
102+
A function (render prop) that takes as argument an object containing the following properties:
104103
105-
The first 3 properties are the `ref` property that is going to be used to retrieve the [React refs](https://reactjs.org/docs/refs-and-the-dom.html) of the **popper** element, the `style` property,
106-
which contains the CSS styles (React CSS properties) computed by Popper.js and needed to style
107-
the **popper** element so that it gets positioned in the desired way.
108-
These styles should be applied to your React component using the `style` prop or with any CSS-in-JS
109-
library of your choice.
110-
111-
The `placement` property describes the placement of your popper after Popper.js has applied all the modifiers
112-
that may have flipped or altered the originally provided `placement` property. You can use this to alter the
113-
style of the popper and or of the arrow according to the definitive placement. For instance, you can use this
114-
property to orient the arrow to the right direction.
115-
116-
`scheduleUpdate` is a function you can call to schedule a Popper.js position update. It will directly call the [Popper#scheduleUpdate](https://popper.js.org/popper-documentation.html#Popper.scheduleUpdate) method.
117-
118-
The `arrowProps` argument is an object, containing a `style` and `ref` properties that are identical to the
119-
ones provided as first and second argument of `children`, but are relative to the **arrow** element rather than
120-
the popper. Use them to, accordingly, retrieve the ref of the **arrow** element and style it.
104+
- **`ref`**: used to retrieve the [React refs](https://reactjs.org/docs/refs-and-the-dom.html) of the **popper** element.
105+
- **`style`**: contains the necessary CSS styles (React CSS properties) which are computed by Popper.js to correctly position the **popper** element.
106+
- **`placement`**: describes the placement of your popper after Popper.js has applied all the modifiers
107+
that may have flipped or altered the originally provided `placement` property. You can use this to alter the
108+
style of the popper and or of the arrow according to the definitive placement. For instance, you can use this
109+
property to orient the arrow to the right direction.
110+
- **`outOfBoundaries`**: a boolean signifying if the popper element is overflowing its boundaries.
111+
- **`scheduleUpdate`**: a function you can call to schedule a Popper.js position update. It will directly call the [Popper#scheduleUpdate](https://popper.js.org/popper-documentation.html#Popper.scheduleUpdate) method.
112+
- **`arrowProps`**: an object, containing `style` and `ref` properties that are identical to the
113+
ones provided as the first and second arguments of `children`, but relative to the **arrow** element. The `style` property contains `left` and `top` offset values, which are used to center the arrow within the popper. These values can be merged with further custom styling and positioning. See [the demo](https://github.com/FezVrasta/react-popper/blob/8994933c430e48ab62e71495be71e4f440b48a5a/demo/styles.js#L100) for an example.
121114
122115
##### `innerRef`
116+
123117
```js
124118
innerRef?: (?HTMLElement) => void
125119
```

0 commit comments

Comments
 (0)