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
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,32 @@ const Button = styled.button`

The same can be done when you `applyResponsiveStyleModifiers` _(deprecated)_.

## TypeScript example

```ts
import styled from "styled-components"
import { applyStyleModifiers, WithModifiers, ModifiersConfig } from "styled-components-modifiers"

// Example of modifiers with typing
const MODAL_MODIFIERS: ModifiersConfig = {}

// Example of a styled component optionally accepting "modifiers" prop
const MyStyledWrapper = styled.div<WithModifiers>`
max-width: 800px;
${applyStyleModifiers(MODAL_MODIFIERS)}
`;

// Example of a custom component optionally accepting modifiers
interface MyComponentProps extends WithModifiers {
children: React.ReactNode;
}

// Will be typed as expected
export const MyComponent = ({ children, modifiers }: MyComponentProps) => (
<MyStyledWrapper modifiers={modifiers}>{children}</MyStyledWrapper>
);
```

## Built with Styled Components Modifiers

Here's your chance to showcase work you are proud of! Feel free to add a link to
Expand Down