npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

ngx-overflow-reveal

v0.6.0

Published

Angular directive to reveal full text on hover when overflowed.

Downloads

289

Readme

ngx-overflow-reveal

npm version npm size license demo

ngx-overflow-reveal is an Angular directive that automatically reveals the full text content on hover when it's overflowing its container. Perfect for truncated text, table cells, and responsive UIs.

Features

  • Automatic Detection - Detects text overflow automatically (both horizontal and vertical)
  • Hover Reveal - Shows full content in an overlay panel on mouse hover
  • Smart Positioning - Automatically adjusts position to stay within viewport bounds
  • Style Preservation - Matches typography, colors, and styling from the original element
  • Background Inference - Intelligently detects background color to ensure proper text visibility
  • Elevation Effect - Optional elevated appearance with subtle shadow
  • Configurable Delay - Optional delay before revealing the content on hover
  • Animation Control - Optional fade-in animation effect when revealing content
  • Lightweight - Zero dependencies (except Angular peer dependencies)
  • Performance Optimized - Runs outside Angular zone for optimal performance
  • Responsive - Updates on window resize and scroll events

Demo

Open the live demo on StackBlitz to try the directive without installing anything:

  • Online demo: https://stackblitz.com/github/hosembafer/ngx-overflow-reveal

Installation

npm install ngx-overflow-reveal

Usage

Import the directive in your component:

import { Component } from '@angular/core';
import { NgxOverflowRevealDirective } from 'ngx-overflow-reveal';

@Component({
  selector: 'app-demo',
  imports: [NgxOverflowRevealDirective],
  template: `...`
})
export class DemoComponent {
  longDescription = 'This is a very long description that would overflow the table cell...';
}

Apply it to any element that may overflow:

<!-- Basic usage -->
<div
  ngxOverflowReveal
  style="width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
  This is a very long text that will be truncated and revealed on hover
</div>

<!-- All options combined -->
<div
  ngxOverflowReveal
  [ngxOverflowRevealElevated]="true"
  [ngxOverflowRevealDelay]="500"
  [ngxOverflowRevealAnimated]="false"
  [ngxOverflowRevealMaxWidth]="400"
  [ngxOverflowRevealViewportPadding]="48"
  style="width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
  Fully customized reveal with all options
</div>

<!-- Table cell example -->
<table>
  <tr>
    <td
      ngxOverflowReveal
      [ngxOverflowRevealElevated]="true"
      style="max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
      {{ longDescription }}
    </td>
  </tr>
</table>

API

Directive Selector

[ngxOverflowReveal]

Inputs

| Input | Type | Default | Description | |-------|------|---------|-------------| | ngxOverflowRevealElevated | boolean | false | Enables elevated appearance with box shadow for the reveal panel | | ngxOverflowRevealDelay | number | 120 | Delay in milliseconds before revealing the content on hover | | ngxOverflowRevealAnimated | boolean | true | Enables fade-in animation when revealing content | | ngxOverflowRevealMaxWidth | number \| undefined | undefined | Maximum width in pixels for the revealed panel. When set, constrains the panel width while preserving left alignment. Content will wrap if it exceeds this width. | | ngxOverflowRevealViewportPadding | number | 24 | Space in pixels between the revealed panel and the viewport edge. Used when automatically constraining panel width to prevent overflow. | | ngxOverflowRevealPanelClass | string \| string[] \| undefined | undefined | CSS class(es) to apply to the revealed panel. Allows full customization of panel styling (e.g., custom shadow, border, background). Can be a single class name or an array of class names. |

Behavior

The directive automatically:

  1. Detects overflow - Monitors both scrollWidth > clientWidth and scrollHeight > clientHeight
  2. Creates reveal panel - Generates a fixed-position overlay on mouseenter
  3. Matches styles - Copies typography, colors, padding, and font rendering properties
  4. Infers background - Walks up the DOM tree to find the first opaque background color
  5. Adjusts position - Repositions if the panel would overflow the viewport
  6. Cleans up - Removes panel on mouseleave and handles all event cleanup

Style Mirroring

The following styles are automatically mirrored from the host element to the reveal panel:

  • Typography: fontFamily, fontSize, fontWeight, fontStyle, letterSpacing, lineHeight
  • Text rendering: fontVariantNumeric, fontKerning, textRendering, -webkit-font-smoothing, -moz-osx-font-smoothing
  • Text styling: color, textTransform, textDecoration
  • Layout: Base padding values (with additional padding in revealed state)

Browser Compatibility

Works with all modern browsers that support:

  • ResizeObserver API
  • MutationObserver API
  • ES2015+

Performance Considerations

  • All mouse and scroll event listeners run outside Angular zone for optimal performance
  • ResizeObserver and MutationObserver are used for efficient change detection
  • Panel is created on-demand (only when overflow is detected)
  • Proper cleanup on component destroy prevents memory leaks

Development

Build the library

ng build ngx-overflow-reveal

Run the demo

You can run the demo locally:

ng serve

Navigate to http://localhost:4200/ to see the demo application.

Or open the live demo on StackBlitz to try it online without installing:

  • Online demo: https://stackblitz.com/github/hosembafer/ngx-overflow-reveal

Run tests

ng test ngx-overflow-reveal

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT © Rafayel Hovhannisyan