Home

Awesome

ngx-spotlight

<a href="https://ngxui.com" target="_blank" style="display: flex;gap: .5rem;align-items: center;cursor: pointer; padding: 0 0 0 0; height: fit-content;"> <img src="https://ngxui.com/assets/img/ngxui-logo.png" style="width: 64px;height: 64px;"> </a>

This Library is part of the NGXUI ecosystem. <br> View all available components at https://ngxui.com

@omnedia/ngx-spotlight is an Angular library that creates a spotlight effect using SVG animations. The component highlights sections of your page when they enter the viewport, with customizable spotlight colors and optional animations. This is ideal for drawing attention to important content as users scroll through your Angular application.

Features

Installation

Install the library using npm:

npm install @omnedia/ngx-spotlight

Usage

Import the NgxSpotlightComponent in your Angular module or component:

import {NgxSpotlightComponent} from '@omnedia/ngx-spotlight';

@Component({
  ...
    imports:
[
  ...
    NgxSpotlightComponent,
],
...
})

Use the component in your template:


<om-spotlight
  [spotlightColor]="'#ffcc00'"
  [animation]="true"
  styleClass="custom-spotlight"
>
  <h1>Highlighted Content</h1>
</om-spotlight>

How It Works

API


<om-spotlight
  [spotlightColor]="spotlightColor"
  [animation]="animation"
  styleClass="your-custom-class"
>
  <ng-content></ng-content>
</om-spotlight>

Example


<om-spotlight [spotlightColor]="'#ff5733'" [animation]="true" styleClass="spotlight-container">
  <div class="highlighted-content">
    <p>This content is highlighted by the spotlight effect</p>
  </div>
</om-spotlight>

This will create a spotlight effect with a reddish-orange color that animates when the content enters the viewport.

Styling

Custom Spotlight Styling Example

In this example, the spotlight is styled with custom colors via css:


<om-spotlight styleClass="custom-spotlight">
  <div class="content">
    <p>Spotlight Content Here</p>
  </div>
</om-spotlight>
/* Global Style */
.custom-spotlight {
  --om-spotlight-color: #ffcc00;
}

/* Component Style */
.content {
  color: white;
  font-size: 1.5rem;
  position: relative;
  z-index: 2;
}

This example applies a yellow spotlight color.

Contributing

Contributions are welcome. Please submit a pull request or open an issue to discuss your ideas.

License

This project is licensed under the MIT License.