Skip to content

recommended solution for multiple MQs #38

Closed
@VinSpee

Description

@VinSpee

Hi,

what's the current solution for multiple MQs? Multiple media components? How should I compose something like that?

A solution like this feels right to me:

      <Media
        query={{
          sm: {
            minWidth: theme.sizes.z5,
          },
          md: {
            minWidth: theme.sizes.z10,
          },
        }}
      >
        {({ sm, md }) => (
           <div>
               { sm && <span>I am small</span> }
               { md && <span> I am medium</span> }
           </div>
        );
        }
      </Media>

at small would render as:

<div>
   <span>I am small</span>
</div>

and at medium:

<div>
    <span>I am small</span>
    <span>I am medium</span>
</div>

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions