Skip to content

Focus Text

Shift focus between words with a moving frame and soft blur.

LIVE PREVIEWInteract with the component
Just React. No extra dependencies.

Copy the component and its CSS module into your project.

CSS Modules

Usage

Matches your current playground settings.

jsx
import FocusText from "./FocusText";
export default function Example() {
return (
<FocusText
text={"Find your focus."}
defaultIndex={1}
blur={4}
color={"#e8e0f1"}
accentColor={"#d0b8ec"}
style={{
"fontSize": 54,
"fontWeight": 500,
"letterSpacing": "-.055em"
}}
/>
);
}

Using Focus Text

Use a phrase whose individual words can carry emphasis. blur controls the softness of the words outside the selected position.

Use activeIndex with onActiveChange to coordinate the focus with other content, or defaultIndex to set its initial position.

Props

NameTypeRequiredDefaultDescription
textstringNo""Text to split into selectable words.
defaultIndexnumberNo0Initially focused word index.
activeIndexnumberNoundefinedOptional controlled word index.
onActiveChangefunctionNoundefinedCalled with the selected word index on pointer or keyboard input.
blurnumberNo3Blur radius for inactive words in pixels.
colorstringNo"#e8e0f1"Text colour.
accentColorstringNo"#d0b8ec"Corner frame colour.
classNamestringNo""Additional CSS classes, merged with the component styles.
styleCSSPropertiesNoundefinedInline styles for caller-defined sizing and visual overrides.

Related components

Reflection Text

Text Effects

Crisp typography meets a soft, fading reflection beneath the baseline.

Morphing Words

Text Effects

Words dissolve through a soft blur while the headline keeps its width.

Dot Matrix Text

Text Effects

Amber pinpoints form a crisp matrix display with a soft travelling pulse.

Scan Text

Text Effects

A warm scanning light brings a dim headline into focus.