Skip to content

Commit

Permalink
Add extractStyle API description to README
Browse files Browse the repository at this point in the history
close #187

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/ant-design/cssinjs?shareId=XXXX-XXXX-XXXX-XXXX).
  • Loading branch information
afc163 committed Sep 23, 2024
1 parent 3a0664f commit 610eef6
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,31 @@ Create theme object. When same algorithm provided, it will return same object.

Since `@ant-design/cssinjs` use strong constraints for cache hit performance, we recommend to view demo `basic.tsx` for usage and `animation.tsx` for animation usage.

### extractStyle

Extracts the styles from the cache and returns them as a string.

#### Parameters

- `cache` (Cache): The cache instance containing the styles.
- `options` (object | boolean, optional): Options for extracting the styles.
- `plain` (boolean, optional): If true, the styles will be returned in plain format. Default is false.
- `types` (string | string[], optional): The types of styles to extract. Default is ['style', 'token', 'cssVar'].

#### Returns

- (string): The extracted styles as a string.

#### Example

```typescript
import extractStyle from '@ant-design/cssinjs';

const cache = /* your cache instance */;
const styles = extractStyle(cache, { plain: true, types: ['style', 'token'] });
console.log(styles);
```

## Transform

When you need transform CSSObject before inject style. You can use `transformers` to handle this:
Expand Down

0 comments on commit 610eef6

Please sign in to comment.