nandorojo / dripsy

🍷 Responsive, unstyled UI primitives for React Native + Web.
https://dripsy.xyz
MIT License
1.98k stars 77 forks source link

[Typescript] how to type a strict color value ? #302

Closed jsellam closed 4 months ago

jsellam commented 6 months ago

Hi, I'm using a config in a ts file with colors, but I would like to type the color field as strict dripsy color

Capture d’écran 2023-12-28 à 12 39 20

Actually I don't know how to type my color field, I use string, and I have an error in my sx prop 👍

Capture d’écran 2023-12-28 à 12 39 51

Who know what type to use please ?

Thx, Jeremie.

jsellam commented 6 months ago

Ok I have the answer :

type Color = keyof ReturnType<typeof useDripsyTheme>['theme']['colors'];

nandorojo commented 6 months ago

Yes, or you can simply import Theme from dripsy