Skip to content

Commit

Permalink
Improve documentation about adding TypeScript support for the sx prop
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlangelaan committed Feb 20, 2025
1 parent 2992662 commit 56d8873
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -778,17 +778,12 @@ The value provided to `sx` prop can be one of the following:
To use `sx` prop on HTML element, you need to augment the `HTMLAttributes` interface. Add the following code to a file that is included in your tsconfig.json:

```ts
type Theme = {
// your theme type
};
import { SxProp } from '@pigment-css/react';

declare global {
namespace React {
interface HTMLAttributes<T> {
sx?:
| React.CSSProperties
| ((theme: Theme) => React.CSSProperties)
| ReadonlyArray<React.CSSProperties | ((theme: Theme) => React.CSSProperties)>;
sx?: SxProp;
}
}
}
Expand Down

0 comments on commit 56d8873

Please sign in to comment.