stitchesjs / stitches

[Not Actively Maintained] CSS-in-JS with near-zero runtime, SSR, multi-variant support, and a best-in-class developer experience.

Home Page:https://stitches.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CSS type does not provide theme tokens intellisense

GeeWizWow opened this issue · comments

commented

Bug report

Describe the bug

When leveraging the CSS type to create a custom css prop, the resulting type does not include any tokens from the Stitches theme.

To Reproduce

  1. Create a stitches config
    const Config = createStitches({
        theme: {
            colors: {
                primary: 'red',
            },
        },
    });
  2. Declare a type for CSS
    type CSSProp = CSS<typeof Config>;
  3. Leverage this prop in a component
    const MyComp = ({ css }: { css: CSSProp }) => {
        const className = Config.css(css);
        return <p className={className()}>Hello, World!</p>;
    }
  4. Attempt to pass the css prop to MyComp, using theme tokens
    <MyComp
        css={{
            color: '$...',
        }}
    />

Expected behavior

  • Typing $ provides a list of valid tokens
  • Providing a token works, and renders the appropriate CSS value

Actual behavior

  • Typing $ provides no suggestions
  • Providing the token manually works, and renders the appropriate CSS value

Repro

Code Sandbox: https://codesandbox.io/s/polished-glitter-j5decj?file=/src/App.tsx

You have to use the config key from the stitches instance

See the docs
https://stitches.dev/docs/typescript#type-a-css-object