Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

you can not override fontWeight in variant | bug #93

Closed
seeden opened this issue Jun 7, 2022 · 1 comment
Closed

you can not override fontWeight in variant | bug #93

seeden opened this issue Jun 7, 2022 · 1 comment

Comments

@seeden
Copy link
Contributor

seeden commented Jun 7, 2022

You are not able to override fontWeight in your styled() component when you use createInterFont

export default createInterFont({
  family: 'Roboto',
  weight: {
    6: 'normal',
  },
});
import { SizableText } from 'tamagui';

export const ExtendedSizableText = styled(SizableText, {
  name: 'ExtendedSizableText',
  variants: {
    bold: {
      true: {
        fontWeight: 'bold',
      },
      false: {
        fontWeight: 'normal',
      },
    },
});

When you try to use prop bold, it will be "ignored." Not ignored but overridden by element style object, which has higher priority.

return (
   <ExtendedSizableText bold />
);

I used "temp hack" with an undefined value, but it is not working from version 56 because of typescript.

export default createInterFont({
  family: 'Roboto',
  weight: {
    6: undefined,
  },
});

I also tried to use !important but there is no support for it :)

export const ExtendedSizableText = styled(SizableText, {
  name: 'ExtendedSizableText',
  variants: {
    bold: {
      true: {
        fontWeight: 'bold !important',
      },
      false: {
        fontWeight: 'normal',
      },
    },
});

Environment (please complete the following information):

  • OS: Mac
  • Browser safari
  • Versions: all (56)
@natew
Copy link
Member

natew commented Jun 26, 2022

Tested this on the upcoming release and not seeing the bug compiler/not-compiled, likely fixed with the fix to styled(Input).

@natew natew closed this as completed Jun 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants