Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions docs/typescript.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,26 @@ const StyledOriginal = styled(Original, {
;<StyledOriginal prop1="1" prop2={2} />
```

Alternatively, you can destructure and split custom props from intrinsic props:

```ts
import { ComponentProps } from 'react';
import styled from '@emotion/styled';
import { css } from '@emotion/react';

type InputWrapperProps = ComponentProps<'div'> & { disabled?: boolean };

const InputWrapper = styled(
({ disabled, ...rest }: InputWrapperProps) => <div role="group" {...rest} />
)`
${({ disabled }) => css`
input {
background: ${disabled ? 'red' : 'white'};
}
`}
`;
```

### Passing props when styling a React component

```tsx
Expand Down