tamagui: Custom Button with theme and variant doesn't have the correct background/color
Current Behavior
I added custom themes like this:
const light_primary = createTheme({
mycolor: 'blue',
mybg: 'red',
})
const light_primary_Button = createTheme({
mycolor: 'white',
mybg: 'tomato',
})
And created a styled Button like this:
const MyButton = styled(Button, {
name: 'Button',
variants: {
variant: {
solid: {
color: '$mycolor',
backgroundColor: '$mybg',
},
},
},
})
Then I’m using the component like this:
export default function Page() {
return (
<Theme name="light">
<YStack theme="primary" m="$6">
<MyButton variant="solid">Test</MyButton>
</YStack>
</Theme>
)
}
However the resulting button has tomato background and black text.
Expected Behavior
Since the themes should be merging and on the button the final theme should be light_primary_Button and according to that theme, the button should have white text color.
Tamagui Version
1.22.3
Reproduction
https://github.com/la55u/tama-variant-theme-bug See the tamagui.config.ts and pages/index.tsx files
System Info
System:
OS: Linux 6.2 Fedora Linux 37 (Workstation Edition)
CPU: (16) x64 12th Gen Intel(R) Core(TM) i7-1260P
Memory: 9.38 GB / 31.04 GB
Container: Yes
Shell: 5.2.15 - /bin/bash
Binaries:
Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node
Yarn: 3.5.0 - ~/.nvm/versions/node/v18.12.1/bin/yarn
npm: 8.19.2 - ~/.nvm/versions/node/v18.12.1/bin/npm
Browsers:
Chrome: 112.0.5615.121
Firefox: 113.0b9
npmPackages:
@babel/runtime: ^7.18.9 => 7.21.0
@manypkg/cli: ^0.19.1 => 0.19.2
check-dependency-version-consistency: ^3.0.3 => 3.0.3
eslint: ^8.21.0 => 8.39.0
node-gyp: ^9.3.1 => 9.3.1
prettier: ^2.7.1 => 2.8.8
turbo: ^1.8.3 => 1.9.3
typescript: ^4.7.4 => 4.9.5
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 17 (16 by maintainers)
On the reproduction from @deggertsen,
styled(Button)works on web, but not getting the correct colors on mobile. The original button works fine as well (without styled).So the only failing case from the repro is
styled(Button)on native.@natew any idea what might be causing this? Since we have had some changes on that area.