import React, { useState } from 'react';
import { View, ScrollView, Text, StyleSheet, Pressable } from 'react-native';
import {
Ux4gTooltip,
Ux4gRichTooltip,
Ux4gTooltipPlacement,
Ux4gButton,
Ux4gTextButton,
useUx4gTheme,
UX4GColors,
} from '../index';
export const TooltipShowcase: React.FC = () => {
const theme = useUx4gTheme();
const [persistentVisible, setPersistentVisible] = useState(false);
const fallbackIcon = (
);
const placements: Ux4gTooltipPlacement[] = [
'topStart', 'top', 'topEnd',
'bottomStart', 'bottom', 'bottomEnd',
'leftStart', 'left', 'leftEnd',
'rightStart', 'right', 'rightEnd'
];
return (
Standard Tooltips
Tap the badges to see standard tooltips in different placements.
{placements.map((p) => (
{p}
))}
Rich Tooltips
Rich tooltips can contain icons, titles, and actions.
Rich (Tap)
}
>
With Action (Tap)
Auto-Show Tooltips
Tooltips can automatically trigger on mount without any user interaction using the autoShow prop.
Auto Show Target
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
padding: 16,
},
title: {
fontSize: 20,
fontWeight: 'bold',
marginBottom: 8,
},
desc: {
fontSize: 14,
marginBottom: 24,
},
grid: {
flexDirection: 'row',
flexWrap: 'wrap',
justifyContent: 'space-between',
paddingHorizontal: 20,
paddingVertical: 40, // padding to allow tooltips to show
},
gridItem: {
width: '45%',
alignItems: 'center',
marginBottom: 48,
},
row: {
flexDirection: 'row',
justifyContent: 'center',
paddingVertical: 32,
},
targetBox: {
paddingHorizontal: 16,
paddingVertical: 8,
borderRadius: 8,
borderWidth: 1,
alignItems: 'center',
justifyContent: 'center',
}
});