Ngx-bootstrap: Set Tooltip Width and wrap the text

Created on 2 Aug 2016  路  9Comments  路  Source: valor-software/ngx-bootstrap

Hi
Could you please let me know how can we set tooltip width and also wrap the text in single line.

Most helpful comment

@mshirishkumar If you inspect, you'll see the tooltip is placed after the item it's referencing, by default. So you can target it with CSS for widths and stuff.

Example...

HTML

<div class="some-container">
  <button tooltip="My button tooltip with lots and lots of text.">Hover Me</button>
</div>

CSS

.some-container .tooltip .tooltip-inner {
  width: 7em;
  white-space: normal;
}

All 9 comments

@mshirishkumar If you inspect, you'll see the tooltip is placed after the item it's referencing, by default. So you can target it with CSS for widths and stuff.

Example...

HTML

<div class="some-container">
  <button tooltip="My button tooltip with lots and lots of text.">Hover Me</button>
</div>

CSS

.some-container .tooltip .tooltip-inner {
  width: 7em;
  white-space: normal;
}

Thanks brandonreid

If you still have problems getting the effect through you can use the angular /deep/ tag to make your CSS work through angulars encapsulation.

https://angular.io/docs/ts/latest/guide/component-styles.html#!#special-selectors

Thanks Nalha

I try to do the same but cant do that , neither with component styling or using class. Any changes on how you do this?

Well yea, I haven't used Angular for a while now but the documentation says this

The shadow-piercing descendant combinator is deprecated and support is being removed from major browsers and tools. As such we plan to drop support in Angular (for all 3 of /deep/, >>> and ::ng-deep). Until then ::ng-deep should be preferred for a broader compatibility with the tools.

But what about customClass can we use that and how would you change the width using cutsomClass?

Came in this post to see how to make the tooltip wider but the suggestions in first few comments didn't work for me. However I got it to work with the containerClass as follow

HTML

<div placement="top" tooltip="my large text...bla bla bla" containerClass="wider-tooltip"></div>

SASS

.wider-tooltip {
  width: 300px;
  .tooltip-inner {
    max-width: 300px;
  }
}

You may use max-width:content, will work

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tuoitrexuquang picture tuoitrexuquang  路  3Comments

tpiros picture tpiros  路  3Comments

phmello picture phmello  路  3Comments

MrBlaise picture MrBlaise  路  3Comments

juanitavollmering picture juanitavollmering  路  3Comments