Docs
Design tokens
Every surface (colour, spacing, radius, typography, shadow) is a named token. Components only read tokens, so changing a token propagates system-wide.
import { View } from 'react-native';
import { useTheme } from '@polprog/native-ui';
function Banner() {
const theme = useTheme();
return (
<View
style={{
backgroundColor: theme.colors.primaryLight,
padding: theme.spacing.lg,
borderRadius: theme.borderRadius.lg,
}}
/>
);
}
Key points
- useTheme() returns the whole theme: colors, spacing, borderRadius, typography, elevation and the tokens of each component.
- Box, VStack and HStack take token names as props, so a screen rarely needs a raw number.
- Components read only tokens, so one changed token updates every place that uses it.
- Each component has its own token group in theme.components.