styled-components-breakpoint provides utility functions for integrating responsive design breakpoints directly into styled-components using CSS-in-JS. Currently in a 3.0.0-preview.20 release, it offers two primary modes of operation: themeable mixins that leverage styled-components' ThemeProvider to define breakpoints globally, and static mixin factories for scenarios where breakpoints do not need to be dynamic or themed. The library simplifies the creation of media queries, allowing developers to define styles that adapt across different screen sizes (e.g., mobile, tablet, desktop) using an intuitive API like breakpoint('md'). It is designed to complement other related packages such as styled-components-spacing and styled-components-grid, promoting a consistent approach to responsive layouts within styled-components projects. While a formal release cadence isn't specified, its preview status indicates ongoing development towards a stable v3.
npm install styled-components-breakpointVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to set up `styled-components-breakpoint` with a `ThemeProvider` for custom breakpoints, applying responsive styles using the `breakpoint` mixin and mapping values with the `map` mixin.
Monitor the official GitHub repository and changelog for stable releases and migration guides. Consider using v2 if stability is paramount.
Thoroughly test `styled-components-breakpoint` with your specific `styled-components` version. Consider opening an issue on the GitHub repo if compatibility problems arise with newer styled-components versions not covered by the peer dependency.
Create a `styled.d.ts` file (or similar) and use declaration merging:
`import 'styled-components'; declare module 'styled-components' { export interface DefaultTheme { breakpoints: { [name: string]: number; }; } }`Wrap your component tree with `ThemeProvider` and pass a `theme` object containing a `breakpoints` property:
`import { ThemeProvider } from 'styled-components'; const theme = { breakpoints: { ... } }; <ThemeProvider theme={theme}>...</ThemeProvider>`Augment the `DefaultTheme` interface in a declaration file (e.g., `styled.d.ts`):
`import 'styled-components'; declare module 'styled-components' { export interface DefaultTheme { breakpoints: { [name: string]: number; }; } }`Switch to ESM `import` statements:
`import breakpoint, { map } from 'styled-components-breakpoint';`