🚀 Ship faster with premium components 🚀
Search documentation v1.2.0

Spotlight

Highlight important content with a lighting effect

Source Report Issue
Command docs
How to add this block to your project
npm run add Spotlight

Use the Spotlight component to highlight content such as updates, announcements, or releases with a visual effect. They guide users toward key content with a strong center of attention without overwhelming the layout. They can also improve aesthetics as the component adds depth, atmosphere, and a premium feel to interfaces.

Want to use this component as a template? Check out the Spotlight template.
New components v0.8.1
Astro Promotional Card
Introducing two new components: Skeleton and Ribbon!
Unlock code
How to use the Spotlight component in Astro
<Spotlight className="spotlight">
<PromotionalCard
...
className="promotional-card"
/>
</Spotlight>
<style lang="scss">
@use 'webcoreui/config' as *;
.spotlight {
min-height: 600px;
height: 600px;
}
.promotional-card {
@include position(absolute, h-center, t20px);
}
</style>

To use the Spotlight component, simply wrap the elements into the component that you want to highlight. The component will always take the full height of its container.

For demonstration purposes, in the example above, it’s explicitly set to 600px. The element inside the component can be positioned in any way you like. In this example, its positioned absolutely, centered on the horizontal axis and 20px from the top.

To learn more about how to use promotional cards, please see the documentation of the PromotionalCard component.

Spotlight Size

The size of the spotlight can be changed with various props, including the following:

The gradients will grow and shrink between the minimum and maximum values.

Increased spotlight size by 20%
New components v0.8.1
Astro Promotional Card
Introducing two new components: Skeleton and Ribbon!
Unlock code
How to change the size of the spotlight
<Spotlight
radialMinWidth="60%"
radialMaxWidth="70%"
coneMinWidth="80%"
coneMaxWidth="90%"
>
<PromotionalCard ... />
</Spotlight>

Particles

The flying particles can also be customized through the following three props:

Increased particle amount and speed
Unlock code
How to change the behavior of particles
<Spotlight
particleAmount={10}
particleSize={1}
particleDuration={5}
/>

Colors

If you need to change colors to match your brand, you can update hte background and rgbColor props. The rgbColor prop expects a comma-separated list of RGB values in the following format:

Customized colors
Unlock code
How to change colors
<Spotlight
background="#000"
rgbColor="100, 155, 255"
/>

Configuration with CSS

If you would like to keep global component configuration in one place, you can also set the above props through the following CSS variables:

Unlock code
How to configure the component with CSS
/* The following are default values: */
html body {
--w-spotlight-blur: 15px;
--w-spotlight-animation-timing: ease-in-out;
--w-spotlight-radial-min-width: 40%;
--w-spotlight-radial-max-width: 50%;
--w-spotlight-cone-min-width: 60%;
--w-spotlight-cone-max-width: 70%;
--w-spotlight-background: radial-gradient(circle at center, #000 0%, #111 100%);
--w-spotlight-color: 255, 255, 255;
}

API

Unlock code
Component API reference
type SpotlightProps = {
blurAmount?: number
animationTiming?: string
radialMinWidth?: string
radialMaxWidth?: string
coneMinWidth?: string
coneMaxWidth?: string
background?: string
rgbColor?: string
particleAmount?: number
particleSize?: number
particleDuration?: number
className?: string
}
PropDefaultPurpose
blurAmount 15px Sets the amount of blur effect on the spotlight.
animationTiming ease-in-out Sets the animation easing of the spotlight.
radialMinWidth 40% Sets the minimum width of the animated radial gradient.
radialMaxWidth 50% Sets the maximum width of the animated radial gradient.
coneMinWidth 60% Sets the minimum width of the animated cone.
coneMaxWidth 70% Sets the maximum width of the animated cone.
background radial-gradient(#000, #111) Sets the background color of the component.
rgbColor 255, 255, 255 Sets the RGB color of the spotlight and particles.
particleAmount 2 Sets the amount of particles spawned at a set interval.
particleSize 3 Sets the base radius of each particle. Particles can randomly have a smaller or larger size based off this value.
particleDuration 20 Sets the time it takes for the particles to finish animation.
className - Pass additional CSS classes for the component.