CSS type does not provide theme tokens intellisense
GeeWizWow opened this issue · comments
Finn 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
- Create a stitches config
const Config = createStitches({ theme: { colors: { primary: 'red', }, }, });
- Declare a type for CSS
type CSSProp = CSS<typeof Config>;
- Leverage this prop in a component
const MyComp = ({ css }: { css: CSSProp }) => { const className = Config.css(css); return <p className={className()}>Hello, World!</p>; }
- 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
Ivan Banov commented
You have to use the config key from the stitches instance
See the docs
https://stitches.dev/docs/typescript#type-a-css-object