package
Simple helper components to make responsive design easier in React.
npm install react-matchesGitHub-flavored package documentation.
Across all versions, last 30 days.
630 in 30 days
Runtime metadata.
Tagged topics.
Simple helper components to make responsive design easier in React.
yarn add react-matches
npm install react-matches --save
import { Media, Container } from 'react-matches'
const queries = {
sm: {
maxWidth: 400
},
md: {
minWidth: 600
},
lg: {
minWidth: 960
}
}
const ResponsiveMediaComponent = () => (
<Media queries={queries}>
{({ matches, resolve }) =>
<Row>
<Column size={resolve({ sm: 12, md: 6, lg: 4 })}>
...
Mediaqueries: PropTypes.objectPass any valid query that you can pass to json2mq.
onUpdate: PropTypes.funcA prop callback that fires when a query has changed.
children: PropTypes.funcChildren must be a function. It returns the following back:
{
matches, // an object matching your queries shape with active queries
resolve // an easier way to work with multiple boolean operations
}Containertag: PropTypes.oneOfType([PropTypes.string, PropTypes.bool])The tag to render. Pass any regular element props along with this. If set to false a containerRef function will be passed down that must be placed on an element ref.
queries: PropTypes.objectAn object of queries using { minWidth, maxWidth, minHeight, maxHeight }.
{
sm: { maxWidth: 399 },
md: { minWidth: 400 },
lg: { minWidth: 800, maxWidth: 1200 },
}onUpdate: PropTypes.funcA prop callback that fires when a query has changed.
children: PropTypes.funcChildren must be a function. It returns the following back:
{
containerRef, // if tag is false, you must pass the containerRef down to the component you want measured
matches, // an object matching your queries shape with active queries
resolve // an easier way to work with multiple boolean operations
}clone repo
git clone git@github.com:souporserious/react-matches.git
move into folder
cd ~/react-matches
install dependencies
yarn
run dev mode
yarn dev
open your browser and visit: http://localhost:8080/
Huge thank you to Daiwei Lu and Michael Jackson. Most of the code in here is heavily inspired by what they have done.
Estimated unpacked size across 9 packages.
270.8 kB
Includes dependencies.
3 direct dependencies.