Skip to content

Commit

Permalink
docs: add TwcComponentProps to API ref
Browse files Browse the repository at this point in the history
  • Loading branch information
gregberge committed Dec 23, 2023
1 parent 36f462b commit 3e2f553
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
18 changes: 14 additions & 4 deletions website/pages/docs/api-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

List of exports available from `react-twc` package.

## `twc`
### `twc`

Builds a `twc` component.

Expand All @@ -12,7 +12,7 @@ import { twc } from "react-twc";
const Title = twc.h2`font-bold`;
```

## `createTwc`
### `createTwc`

Create a custom instance of `twc`.

Expand All @@ -26,12 +26,12 @@ const twx = createTwc({
});
```

### Options
#### Options

- `compose`: The compose function to use. Defaults to `clsx`.
- `shouldForwardProp`: The function to use to determine if a prop should be forwarded to the underlying component. Defaults to `prop => prop[0] !== "$"`.

## `cx`
### `cx`

Concatenates class names (an alias of [`clsx`](https://github.com/lukeed/clsx)).

Expand All @@ -40,3 +40,13 @@ import { cx } from "react-twc";

const className = cx(classes);
```

### `TwcComponentProps<Component, Compose = typeof clsx>`

Returns props accepted by a `twc` component. Similar to `React.ComponentProps<"button">` with `asChild` prop and `className` type from `clsx`.

```tsx
import type { TwcComponentProps } from "react-twc";

type ButtonProps = TwcComponentProps<"button">;
```
6 changes: 5 additions & 1 deletion website/pages/docs/guides/_meta.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"as-child-prop": "asChild prop",
"class-name-prop": "className prop"
"class-name-prop": "className prop",
"refs": "Refs",
"styling-any-component": "Styling any component",
"additional-props": "Additional props",
"adapting-based-on-props": "Adapting based on props"
}

0 comments on commit 3e2f553

Please sign in to comment.