Skip to content

Commit f671122

Browse files
gabrieljablonskiGabriel Jablonski
authored andcommitted
docs: improve usage guide for default css styling
1 parent 92fc5ef commit f671122

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,15 @@ yarn add react-tooltip
4747

4848
### Using NPM
4949

50-
1 . Require react-tooltip after installation
50+
1 . Import the CSS file to set default styling
51+
52+
```js
53+
import 'react-tooltip/dist/react-tooltip.css'
54+
```
55+
56+
This needs to be done only once. We suggest you do it on your `src/index.js` or equivalent file.
57+
58+
2 . Import `react-tooltip` after installation
5159

5260
```js
5361
import { Tooltip } from 'react-tooltip'
@@ -59,15 +67,15 @@ or if you want to still use the name ReactTooltip as V4:
5967
import { Tooltip as ReactTooltip } from 'react-tooltip'
6068
```
6169

62-
2 . Add `data-tooltip-content="your placeholder"` to your element
70+
3 . Add `data-tooltip-content="your placeholder"` to your element
6371

6472
```jsx
6573
<p id="my-element" data-tooltip-content="hello world">
6674
Tooltip
6775
</p>
6876
```
6977

70-
3 . Include react-tooltip component
78+
4 . Include react-tooltip component
7179

7280
```jsx
7381
<ReactTooltip anchorId="my-element" />

docs/docs/examples/styling.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ import 'react-tooltip/dist/react-tooltip.css'
365365

366366
#### Observation
367367

368-
This doc is only if you are importing `import 'react-tooltip/dist/react-tooltip.css'`, if not, you can write your classes by you directly.
368+
This doc is only if you are importing `import 'react-tooltip/dist/react-tooltip.css'`. If not, you can write your own CSS classes directly.
369369

370370
With CSS specificity everything can be overridden if you know what are you doing.
371371

docs/docs/getting-started.mdx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ yarn add react-tooltip
4949

5050
## Usage
5151

52+
### Set the default styling
53+
54+
```js
55+
import 'react-tooltip/dist/react-tooltip.css'
56+
```
57+
58+
This needs to be done only once. We suggest you do it on your `src/index.js` or equivalent file.
59+
For advanced styling, check [the examples](./examples/styling.mdx).
60+
5261
There are two ways to use ReactTooltip.
5362

5463
1. Using props into ReactTooltip Element.
@@ -124,9 +133,8 @@ By default, you can't interact with elements inside the tooltip. To allow for pr
124133

125134
### Styling
126135

127-
If you want a styled tooltip, don't forget to add the style file `import 'react-tooltip/dist/react-tooltip.css'`.
128-
129136
Basic styling can be done by overriding the following css variables.
137+
For advanced styling, check [the examples](./examples/styling.mdx).
130138

131139
```css
132140
:root {
@@ -139,5 +147,3 @@ Basic styling can be done by overriding the following css variables.
139147
--rt-opacity: 0.9;
140148
}
141149
```
142-
143-
For advanced styling, check [the examples](./examples/styling.mdx).

0 commit comments

Comments
 (0)