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

export type of css function #1151

Open
majidsajadi opened this issue Apr 5, 2023 · 2 comments
Open

export type of css function #1151

majidsajadi opened this issue Apr 5, 2023 · 2 comments

Comments

@majidsajadi
Copy link

majidsajadi commented Apr 5, 2023

Is your feature request related to a problem? Please describe.
Im using React context API for exposing created stitches config to the components. I want to store css in context but there is no exported type.

Describe the solution you'd like
Export css and styled types.

Describe alternatives you've considered
Im currently using typeof css operator.

@majidsajadi majidsajadi changed the title export type of css and styled functions export type of css function Apr 5, 2023
@aaort
Copy link

aaort commented May 1, 2023

If I understood your intentions properly you can get the type of css object returned from the createStitches method by importing Stitches as default and accessing css property like this: Stitches['css'].

@wbobeirne
Copy link

Because the css function & component prop is dynamic based on the configuration you pass to createStitches, it can't be provided as a static import. What I've done for my project is export a type in my stitches.config.ts:

import { CSS, createStitches } from '@stitches/react'

export const {
    styled,
    css,
    globalCss,
    keyframes,
    getCssText,
    theme,
    createTheme,
    config,
} = createStitches({ /* your config here */ })

export type CSSProp = CSS<typeof config>

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

3 participants