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

Styled Component type definitions #13

Closed
zwgnr opened this issue Dec 15, 2022 · 0 comments
Closed

Styled Component type definitions #13

zwgnr opened this issue Dec 15, 2022 · 0 comments

Comments

@zwgnr
Copy link

zwgnr commented Dec 15, 2022

First of all, thank you so much for making this library, great stuff!

Is there currently a way to get Styled Component variant type definitions? Not sure if I am doing something wrong. Take a simple button using the traditional Vanilla Extract Recipe.

const ButtonWithRecipe = recipe({
  base: {
    backgroundColor: 'gainsboro',
    borderRadius: '9999px',
  },
  variants: {
    sm: { padding: '12px' },
    md: { padding: '16px' },
  },
});

//When using the RecipeVariants import the correct type is returned
export type ButtonRecipeVariants = RecipeVariants<typeof ButtonWithRecipe>;

When recreating that same thing as a Styled Component I am having trouble getting the correct type definitions.

const StyledButton = styled('button', {
    base: {
      backgroundColor: 'gainsboro',
      borderRadius: '9999px',
      fontSize: '13px',
      border: '0',
    },
    variants: {
      sm: { padding: '12px' },
      md: { padding: '16px' },
    },
  });

//I am able to get type definitions for the _entire_ component including DOM props with the following, 
export type WithDOMProps = React.ComponentProps<typeof StyledButton>;

//With the provided StyleVariants import the style always returns "type StyledButtonVariants = unknown"
export type StyledButtonVariants = StyleVariants<typeof ButtonWithRecipe>;
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

1 participant