shadcn.io is not affiliated with official shadcn/ui
Gloss Text makes a word look like glossy plastic or hard candy: one bright colour with a wet sheen over the top of the letters, a darker belly, a lighter bottom edge and a soft glow underneath. A bright highlight sits near the top like a light above; move the pointer over the text and it follows, gliding across the letters, then drifts back when the pointer leaves.
Use it for a playful, tactile word: a consumer product, a sweet shop, a call to action, a retro hero. For neutral metal that shines by itself, use Chrome Text; for a rainbow finish, Foil Text; for a flat flowing gradient, Gradient Text. Every layer is a background clipped to the letters; the pointer writes the highlight's place into two registered CSS properties and a transition eases it there, with no animation library.
Installation
Usage
import { GlossText } from "@/components/ui/gloss-text";<h2>
<GlossText text="Sweet!" />
</h2>Demos
Colors
baseColor is the plastic's colour, any CSS colour, including your theme's variables such as var(--primary); the sheen, the darker belly, the bottom edge and the glow are all mixed from it.
Intensity
intensity is how shiny it is: subtle for satin, medium by default, strong for wet lacquer.
Accessibility
The text stays real text, read by screen readers and selectable. Choose a baseColor that contrasts with the page: the sheen lightens the top of the letters, so a mid-tone reads best. In forced-colors mode, where backgrounds are removed, the text falls back to the system's text colour. The highlight only moves when the pointer does.
FAQ
How does the highlight follow the pointer?
On each move over the text, the pointer's place is written into two CSS variables, --gloss-text-x and --gloss-text-y. They're registered as percentages, so a transition eases the highlight there instead of jumping; leaving removes them, and it glides back to rest.
Where does the highlight rest?
High and centred, at 50% across and 28% down, like a light above the letters: where a glossy surface lit from above shows its brightest spot.
What happens on a touch screen?
The gloss shows with its highlight at rest, its sheen and its belly; nothing depends on the highlight moving.
How is it different from Chrome Text?
Chrome is neutral metal, light and dark bands with a sweep of light on its own. Gloss is one bright colour with a soft sheen and a highlight you move with the pointer: plastic rather than metal.
API Reference
GlossText
<span> data-slot="gloss-text"
textstring
The text.
baseColor?string
The plastic's colour, any CSS colour; its sheen, its darker belly and its glow are mixed from it. By default a candy pink.
intensity?"subtle" | "medium" | "strong"
How shiny it is: subtle for satin, medium, or strong for wet
lacquer.
- Type
"subtle" | "medium" | "strong"- Default
"medium"
render?ReactElement | ((props: object, state: object) => ReactElement)
Replace the host element or compose it with another component.
- Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string
Merged with the part's classes.
--gloss-text-colorstring
The plastic's colour.
Related
- Pro
Chrome Text
DecorativeNeutral metal that shines by itself
- Pro
Foil Text
DecorativeA rainbow finish under the pointer
Gradient Text
DecorativeA flat gradient that flows
- Pro
Handcrafted
Emboss Text
DecorativeLight and shade, pressed into the page
- Pro
Every detail deserves the spotlightEvery detail deserves the spotlight
Spotlight Text
InteractiveA beam that follows the pointer
- Pro
Wobble Text
MotionJelly letters that rock when pointed at