Skip to content

Commit 3c0c8e8

Browse files
Update react-jss-ts.md (#1623)
- Fix typo in line 111 (Thme -> Theme) - Added a section on how to use the custom theme type defined in global.d.ts
1 parent 6951794 commit 3c0c8e8

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

docs/react-jss-ts.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ If `CustomTheme` is the same across your entire application, you can define a de
108108

109109
declare global {
110110
namespace Jss {
111-
export interface Thme {
111+
export interface Theme {
112112
background: string
113113
}
114114
}
@@ -118,3 +118,18 @@ export {}
118118
```
119119

120120
This enables React-JSS to rely on a default `Theme` type, removing the need to explicitly provide a type to `createUseStyles`. This file does not need to be imported anywhere; it is automatically acknowledged by TypeScript and/or VSCode's TypeScript Server.
121+
122+
123+
## Using your Global Default Theme
124+
125+
After defining your custom theme type in `global.d.ts`, as shown above, you can import and use the custom theme interface as follows:
126+
127+
```typescript
128+
// theme.tsx
129+
130+
import { DefaultTheme } from "react-jss";
131+
132+
export const theme: DefaultTheme = {
133+
"background": "#fafafa",
134+
};
135+
```

0 commit comments

Comments
 (0)