-
Notifications
You must be signed in to change notification settings - Fork 145
Closed
Description
What is the best way to style dynamic components, which style could change (i.e. during user interaction)?
For instance, I've created this custom Button component:
type Props = SpacingShorthandProps<Theme> &
VariantProps<Theme, 'buttonVariants'> & {
label?: string;
onPress: () => void;
};
export const Button = ({ label, onPress, ...rest }: Props) => {
const props = useRestyle(restyleFunctions, rest);
return (
<Pressable onPress={onPress} {...props}>
<Text variant="text">{label}</Text>
</Pressable>
);
};
and using it like this somewhere outside:
<Button variant='primary' onPress={_onPress} label='Submit' />
So the task is to somehow apply different styles when button is being pressed. Do I need to create another variant but for pressed state (like, primaryPressed) and somehow change the variant from outside? Or is there something I missed when reading docs and there's easier way to do this?
Janushan, DenisDov, dmic89, flexbox, ha3 and 12 more
Metadata
Metadata
Assignees
Labels
No labels