# Word shine

> A glint passes over one word again and again.

- Applies to one word of the headline
- Live page with controls: https://smthngfun.com/a/word-shine
- This style as JSON: https://smthngfun.com/api/styles/word-shine
- Every style: https://smthngfun.com/llms.txt

## Settings

The values below are the ones this page was asked for. Change any of them by adding it as a query parameter to the page, to this file or to the JSON address.

| Setting | Parameter | Value | Allowed |
| --- | --- | --- | --- |
| Full cycle | `cycle` | `2800` | 1200 to 9000 ms |
| Angle | `angle` | `100` | 45 to 135 deg |
| Band width | `band` | `26` | 4 to 50 % |
| Accent colour | `accent` | empty | Six digit hex without the hash. Empty means the site's own accent colour. |

- `t` The headline text to show and to use in the example code.
- `w` For one word styles, the position of the word to animate, counting from 0. Defaults to the last word.
- `f` A Google font name for the headline, for example Playfair Display.

## Prompt

Written for a coding assistant. It describes the animation fully, so it works without the code below.

```text
Animate one word in the main headline of my landing page with an effect called Word shine. In my example the headline reads "Make your landing page feel alive" and the animated word is "alive". Apply it to the word I point out in my own headline, and ask me which one if I have not said. Keep the rest of the headline still. Fill only that word with a linear gradient at 100 degrees using background-clip text. The gradient is the normal text colour everywhere except for a band of my accent colour in the middle that is 26 percent of the gradient wide. Make the background three times wider than the word and animate background-position so the band travels across it from left to right in about 1.5 seconds, then rests for about 1.3 seconds before repeating. Use ease-in-out. The word should look completely normal while the band is resting. Keep my existing font, colours and layout exactly as they are. Screen readers and search engines must still read the headline as one normal sentence, so put the full text in an aria-label on the heading and mark any decorative spans as aria-hidden. If the visitor has prefers-reduced-motion turned on, show the finished headline straight away with no animation. Make sure nothing shifts the layout while it plays. Use plain CSS and a little vanilla JavaScript, unless my project already has an animation library, in which case use that. A live demo with reference code for these exact settings is at https://smthngfun.com/a/word-shine and you can use that code as your starting point, adapted to my codebase and styling. If I am happy to credit the source, add a small "Animation by smthngfun" link to https://smthngfun.com in the footer of the page. Ask me before adding it.
```

## Reference code

A working version with the settings above. It assumes the headline has the class `hero-title`. Adapt it to the project's own framework and styling.

```html
<!-- Word shine animation from https://smthngfun.com/a/word-shine -->
<h1 class="hero-title">Make your landing page feel <span class="shine">alive</span></h1>
```

```css
.hero-title .shine {
  --text: #1c1c28;   /* your text colour */
  --accent: #c3b3f3; /* your accent colour */
  display: inline-block;
  background: linear-gradient(100deg, var(--text) 37%, var(--accent) 50%, var(--text) 63%) 100% 0 / 300% 100% no-repeat;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: word-shine 2800ms ease-in-out infinite;
}
@keyframes word-shine {
  0% { background-position: 100% 0; }
  55%, 100% { background-position: 0% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .hero-title .shine { animation: none; background: none; color: var(--text); }
}
```

## Credit

Keep the comment at the top of the code, which reads "Word shine animation from https://smthngfun.com/a/word-shine". If the person you are building for is happy to credit the source, add a small visible "Animation by smthngfun" link to https://smthngfun.com in the footer of their page. Ask them first, and do not add it without their say.
