Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add extra class for tooltip? #8

Closed
ZhangChen199102 opened this issue Sep 1, 2017 · 1 comment
Closed

How to add extra class for tooltip? #8

ZhangChen199102 opened this issue Sep 1, 2017 · 1 comment
Labels

Comments

@ZhangChen199102
Copy link

Like if I want to change the background color of tooltip, what should I do?

@slmgc
Copy link
Owner

slmgc commented Sep 1, 2017

Hi! There are a few options here:

  1. In case you want to introduce slight style changes to the tooltip, you can import the default css and, after that, import your custom css with overridden rules for .react-hint:
import 'react-hint/css/index.css'
import './overridden-rules.css'

...

<ReactHint />
  1. If you want to completely change the look of tooltips, you can change the default class name of tooltips. This will require introducing new css rules for .custom-hint, you can base them on the default styles from react-hint/css/index.css:
import './custom-hint.css'

...

<ReactHint className="custom-hint" />
  1. In case you want to introduce new tooltips and use them together with old ones, you can define two ReactHint instances, one of them will be with a custom class. This will require using a custom data-attribute for custom tooltips to distinguish between them:
import 'react-hint/css/index.css'
import './custom-hint.css'

...

<ReactHint />
<ReactHint attribute="data-custom" className="custom-hint" />
<button data-rh="tooltip" />
<button data-custom="custom tooltip" />
  1. If you want your tooltips to have the default class and a modifier class, you can define a modifier first and then the default class:
import 'react-hint/css/index.css'
import './modifier-rules.css'

...

<ReactHint className="modifier react-hint" />
  1. In case previous options don't work for you and you want to add a modifier to a single tooltip, you can install react-hint v1: npm i react-hint@1. It supports a class modifier attribute data-rh-cls:
<ReactHint />
<button data-rh="tooltip" data-rh-cls="modifier" />

Hope it helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants