GithubHelp home page GithubHelp logo

Comments (5)

dragma avatar dragma commented on September 10, 2024 1

This is not possible for you to think that way.
Bootstrap layout css is made so you can hide or show or resize things depending on your browser resolution.
styled-component is a library that mostly generates css code, and inject it in the dom.

Maybe you should rethink your component so it adapts its design to the given breakpoints.

Example :

import React from 'react';
import styled from 'styled-components';
import { media } from 'styled-bootstrap-grid';

const Comp = styled.div`
  display: none;
  ${media.md` // larger than 'md' breakpoint
    display: initial;
  `}
  ${media.lg` // larger than 'lg' breakpoint
    display: none;
  `}
`;

const SomeComponent = props => (
  <div>
    <Comp>Hide if not md</Comp>
  </div>
);

export default SomeComponent;

from styled-bootstrap-grid.

dragma avatar dragma commented on September 10, 2024

Media is already exposed !

Try this !

import { media } from 'styled-bootstrap-grid';
import styled from 'styled-components';

const MyComponent = styled.div`
  ${media.xl`
    display: none;
  `}
`;

export default MyComponent;

from styled-bootstrap-grid.

checkonetwo avatar checkonetwo commented on September 10, 2024

I mean something like in my Page.js:

{ currentBreakpoint === 'md' ? <SomeComponent /> : null }

main thing is not hiding component with css
main thing is do not render something with some breakpoints

from styled-bootstrap-grid.

checkonetwo avatar checkonetwo commented on September 10, 2024

Thank you anyway! I will try to do it by my self
Thread could be close

from styled-bootstrap-grid.

kopax avatar kopax commented on September 10, 2024

I would recommend an alternative, using bootstrap-styled:

There is a similar implementation of withWidth as material-ui:

import withWidth from 'bootstrap-styled/lib/withWidth';

export default withWidth({ logging: true })(MyComponent);

It should also work with this package, as long as you have theme['$grid-breakpoints´] in your theme.

from styled-bootstrap-grid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.