diff --git a/README.md b/README.md index 9609c401..f0ddf827 100755 --- a/README.md +++ b/README.md @@ -47,7 +47,15 @@ yarn add react-tooltip ### Using NPM -1 . Require react-tooltip after installation +1 . Import the CSS file to set default styling + +```js +import 'react-tooltip/dist/react-tooltip.css' +``` + +This needs to be done only once. We suggest you do it on your `src/index.js` or equivalent file. + +2 . Import `react-tooltip` after installation ```js import { Tooltip } from 'react-tooltip' @@ -59,7 +67,7 @@ or if you want to still use the name ReactTooltip as V4: import { Tooltip as ReactTooltip } from 'react-tooltip' ``` -2 . Add `data-tooltip-content="your placeholder"` to your element +3 . Add `data-tooltip-content="your placeholder"` to your element ```jsx

@@ -67,7 +75,7 @@ import { Tooltip as ReactTooltip } from 'react-tooltip'

``` -3 . Include react-tooltip component +4 . Include react-tooltip component ```jsx @@ -79,9 +87,9 @@ You can import `node_modules/react-tooltip/dist/react-tooltip.[mode].js` into yo mode: `esm` `cjs` `umd` -If you want to use default ReactTooltip styles, don't forget to import the styles: `node_modules/react-tooltip/dist/react-tooltip.css` +Don't forget to import the CSS file from `node_modules/react-tooltip/dist/react-tooltip.css` to set default styling. This needs to be done only once in your application. -PS: all the files has a minified version and a not minified version. +PS: all the files have a minified version and a non-minified version. ![image](https://user-images.githubusercontent.com/9615850/205637814-c0ef01ae-bd77-4e7f-b4bf-df502c71e5c3.png) diff --git a/docs/docs/examples/styling.mdx b/docs/docs/examples/styling.mdx index 24a6b060..d39ed3bd 100644 --- a/docs/docs/examples/styling.mdx +++ b/docs/docs/examples/styling.mdx @@ -365,8 +365,6 @@ import 'react-tooltip/dist/react-tooltip.css' #### Observation -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. - With CSS specificity everything can be overridden if you know what are you doing. The necessity of `!important` was removed because `!important` cut a lot of levels/possibilities related to CSS specificity. diff --git a/docs/docs/getting-started.mdx b/docs/docs/getting-started.mdx index 261e091f..acf3218c 100644 --- a/docs/docs/getting-started.mdx +++ b/docs/docs/getting-started.mdx @@ -49,6 +49,15 @@ yarn add react-tooltip ## Usage +### Set the default styling + +```js +import 'react-tooltip/dist/react-tooltip.css' +``` + +This needs to be done only once. We suggest you do it on your `src/index.js` or equivalent file. +For advanced styling, check [the examples](./examples/styling.mdx). + There are two ways to use ReactTooltip. 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 ### Styling -If you want a styled tooltip, don't forget to add the style file `import 'react-tooltip/dist/react-tooltip.css'`. - Basic styling can be done by overriding the following css variables. +For advanced styling, check [the examples](./examples/styling.mdx). ```css :root { @@ -139,5 +147,3 @@ Basic styling can be done by overriding the following css variables. --rt-opacity: 0.9; } ``` - -For advanced styling, check [the examples](./examples/styling.mdx).