Animated shimmer text for streaming, thinking, and loading labels.
Animated shimmer text for streaming, thinking, and loading labels.
import { TextShimmer } from 'heroui-native-pro';The shimmer masks a gradient band to the glyphs with @react-native-masked-view/masked-view, an optional peer dependency. Without it, TextShimmer renders static text and logs a development warning. The sweep runs on iOS and Android only.
npx expo install @react-native-masked-view/masked-viewThe text renders dimmed, and a highlight band sweeps across the glyphs.
<TextShimmer>Thinking...</TextShimmer>className targets the text, as text styles do not inherit through a React Native View. The highlight color and band width derive from the resolved text color and font size.
<TextShimmer className="text-lg font-semibold">Generating response...</TextShimmer>
<TextShimmer className="text-sm text-accent">Searching the web...</TextShimmer>Tune the sweep with animation.shimmer. Every field is optional.
<TextShimmer
animation={{
shimmer: {
duration: 1600,
repeatDelay: 800,
easing: 'ease-in-out',
spread: 24,
color: '#a855f7',
},
}}
>
Thinking...
</TextShimmer>spread is the half-width of the highlight band. A number is in pixels and keeps the band the same size on short and long text. A percent string is relative to the text width, so the band scales with the text.
<TextShimmer animation={{ shimmer: { spread: 16 } }}>Thinking...</TextShimmer>
<TextShimmer animation={{ shimmer: { spread: '25%' } }}>Thinking...</TextShimmer>direction is relative to the reading direction, so 'normal' sweeps right to left in RTL layouts.
<TextShimmer animation={{ shimmer: { direction: 'alternate' } }}>
Syncing...
</TextShimmer>
<TextShimmer animation={{ shimmer: { iterationCount: 3 } }}>
Saved
</TextShimmer>With the animation disabled, the text renders at full strength with no sweep. The same happens when the system "Reduce Motion" setting is on.
<TextShimmer animation={isPending ? undefined : 'disabled'}>
{isPending ? 'Thinking...' : 'Done'}
</TextShimmer>The container hugs the text (align-self: flex-start), so the band sweeps across the glyphs instead of the full row. Override it through classNames.container. Put padding on the text rather than the container so the mask stays aligned.
<TextShimmer classNames={{ container: 'self-center' }}>Loading...</TextShimmer>import { Spinner, Surface } from 'heroui-native';
import { TextShimmer } from 'heroui-native-pro';
import { Text, View } from 'react-native';
export default function TextShimmerExample() {
return (
<View className="flex-1 px-5 items-center justify-center">
<View className="w-full gap-3">
<Surface variant="secondary" className="self-end rounded-3xl px-4 py-3">
<Text className="text-sm text-foreground">
Summarize this quarter's revenue trends
</Text>
</Surface>
<View className="flex-row items-center gap-2">
<Spinner size="sm" />
<TextShimmer
className="text-sm"
classNames={{ container: 'self-center' }}
>
Analyzing 12 reports...
</TextShimmer>
</View>
</View>
</View>
);
}| prop | type | default | description |
|---|---|---|---|
children | ReactNode | - | Text content. Nested Text elements are supported |
className | string | - | Additional CSS classes for the text (readable text and mask copy) |
classNames | ElementSlots<RootSlots> | - | Additional CSS classes for the slots |
styles | TextShimmerStyles | - | Inline styles for the slots |
animation | TextShimmerRootAnimation | - | Animation configuration |
isAnimatedStyleActive | boolean | true | When false, the sweep animation is not applied to the sweep slot, so you can drive it via styles.sweep |
...TextProps | TextProps | - | Forwarded to the readable text. Layout props (numberOfLines, font scaling…) also apply to the mask copy |
ElementSlots<RootSlots>| prop | type | description |
|---|---|---|
container | string | Outer View, sized to the text (align-self: flex-start) |
text | string | Readable text and its mask copy (merged with className) |
sweep | string | Text-sized layer inside the mask that travels across the text |
highlight | string | Gradient band centered on the sweep layer |
The sweep transform and the highlight width, offset, and gradient are computed from animation.shimmer and cannot be set via className.
styles| prop | type | description |
|---|---|---|
container | ViewStyle | Outer View wrapping the text and the mask |
text | TextStyle | Readable text and its mask copy |
sweep | ViewStyle | Text-sized layer that travels across the text |
highlight | ViewStyle | Gradient band carried by the sweep layer |
Animation configuration for the shimmer. Can be:
true or undefined: default sweepfalse or "disabled": no sweep; the text renders at full strength"disable-all": no sweep, and cascades the disabled state to animated descendantsobject: custom sweep configuration| prop | type | default | description |
|---|---|---|---|
state | 'disabled' | 'disable-all' | boolean | - | Disable the sweep while customizing properties |
shimmer.duration | number | 2500 | Duration of a single sweep, in milliseconds |
shimmer.delay | number | 0 | Delay before the first sweep, in milliseconds |
shimmer.repeatDelay | number | 0 | Pause between consecutive sweeps, in milliseconds |
shimmer.easing | CSSAnimationTimingFunction | 'ease' | Timing function of each sweep (keyword, cubicBezier(), steps()…) |
shimmer.direction | CSSAnimationDirection | 'normal' | 'normal' | 'reverse' | 'alternate' | 'alternate-reverse' |
shimmer.iterationCount | CSSAnimationIterationCount | 'infinite' | Number of sweeps, or 'infinite' |
shimmer.spread | TextShimmerSpread | 2.2 × fontSize | Half-width of the highlight band: pixels, or percent of the text width |
shimmer.color | string | resolved text color | Highlight color at the center of the band |
| type | description |
|---|---|
number | Pixels. The band keeps the same size on any text |
`${number}%` | Percent of the text width. The band scales with it |