React Native Mantine › Miscellaneous
FloatingIndicator
Animated indicator that slides between targets
Import: import { FloatingIndicator } from 'react-native-mantine';
Usage
import { FloatingIndicator } from 'react-native-mantine';
import type { FloatingIndicatorTarget } from 'react-native-mantine';
const [active, setActive] = useState(0);
const [rects, setRects] = useState<
(FloatingIndicatorTarget | null)[]
>([null, null, null]);
// Parent uses the default relative positioning
<View style={{ flexDirection: 'row', borderWidth: 1 }}>
{/* Rendered first, sits behind the labels */}
<FloatingIndicator target={rects[active] ?? null} color="blue" />
{labels.map((label, index) => (
<Pressable
key={label}
// Transparent background + zIndex above the indicator
style={{ flex: 1, zIndex: 1 }}
onLayout={(event) => {
const { x, y, width, height } = event.nativeEvent.layout;
setRects((current) => {
const next = [...current];
next[index] = { x, y, width, height };
return next;
});
}}
onPress={() => setActive(index)}
>
<Text>{label}</Text>
</Pressable>
))}
</View>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
target | FloatingIndicatorTarget | null | Layout of the target element relative to the parent, null hides the indicator. Use onLayout of the target to measure it | |
transitionDuration | number | 150 | Transition duration in ms |
radius | number | "xs" | "sm" | "md" | "lg" | "xl" | "sm" | Key of theme.radius or any valid value to set border-radius |
color | MantineColor | Key of theme.colors or any valid color, controls background color | |
children | React.ReactNode | Indicator content | |
style | ViewStyle | Additional styles to apply to the indicator |