News Articles styled-components

In React, When I close the modal, I cannot scroll down/up

I am just getting started learning React with Function Component and Styled-Components. I created Modal Component and when I clicked the modal it shows up and I cannot scroll down/up(Background) but when I close the modal, I cannot scroll. I expect it should be work when I close the modal. Could you help me with […]

How style endIcon of styled-component button?

Here is my simple styled button import styled from ‘styled-components’; import Button from ‘@material-ui/core/Button’; import ArrowForwardIosIcon from ‘@material-ui/icons/ArrowForwardIos’; const MyButton = styled(Button)` font-size: 11px; `; <MyButton variant="outlined" color="primary" size="small" disableElevation endIcon={<ArrowForwardIosIcon />} > CLICK ME </MyButton> So how do I change endIcon size. I can change it in Chrome dev tool but have no idea […]

Changing the order of elements created using ::before and ::after in CSS

I’ve tried to simplify my problem into the below: .wrapper { position: relative; display: inline-flex; min-height: 1.5rem; border: 1px solid black; margin-right: 1rem; padding-right: 1.5rem; } .input { position: absolute; z-index: -1; opactiy: 0; } .label-wrapper { margin-left: 2rem; } .label { position: relative; margin-bottom: 0; } .label:before { position: absolute; top: 4px; left: -24px; […]

How to check whether a string contains a substring in JavaScript(typescript)?

0 I’m trying to make a search field, and I’m already able to do searches, but it only returns posts that are typed with the same title or are exactly the same which would not be interesting, this happens in my conditional if (query !== post .title && query) return null The ideal would be […]

How to search posts with an keyword (strings of strings)?

I’m trying to make a search field, and I’m already able to do searches, but it only returns posts that are typed with the same title or are exactly the same which would not be interesting, this happens in my conditional if (query !== post .title && query) return null The ideal would be to […]

styled-components – Why is global style injected after component styles here?

consider this example of a react-app using styled-components: import styled from "styled-components"; import { createGlobalStyle } from "styled-components"; import React from "react"; const GlobalStyle = createGlobalStyle` [type="submit"] { color: red; } `; const StyledButton = styled.button` color: blue; `; function MyComponent() { return ( <> <h1>My Component</h1> <button type="submit">regular button</button> <StyledButton type="submit">styled button</StyledButton> </> ); […]

Using ::before & ::after pseduo elements to move element from left to right

fairly new to using ::before & ::after with CSS. Here’s what I have so far: I have the checkbox that is created by the before & after on the StyledLabel – I basically just want to swap the order of the checkbox and the label, so that the checkbox comes after (to the right of) […]

Changing CSS Attribute on click in React while using Styled Components

I’m making a web in HTML, CSS, and plain JS. I’m planning to convert this into ReactJS. Although, I’m planning to make this into a single JSX file to export it to App.js. My friend recommended me to use Styled Components so I can make all of it into a single JSX file. The problem […]

Align Icon on Center Using Styled Components

I have an icon that I want to align on center. My problem is that, it doesn’t align well. I’m using styled components. Here’s my codesandbox CLICK HERE const Play = styled.div` position: absolute; top: 50%; left: 50%; `; Source: CSS – Stack Overflow

Using ‘as’ polymorphic prop of styled-components with typescript

I was trying to implement a Typography react component. As you can see below, I got variant as an input prop and used it as index of VariantsMap object to get corresponding html tag name. Then I used styled-components ‘as’ polymorphic prop to render it as selected html tag. but I keep get this error […]

Styled-components is not working with react

Using this yarn add styled-components I install styled components in my react project. but when I am styling using styled-components styling does not work. [Navbar.jsx][1] [package.json][2] [1]: https://i.stack.imgur.com/IyTGi.png [2]: https://i.stack.imgur.com/c6vXj.png Source: React – Stack Overflow

translate a classic css stylesheet to react styled-component use + selector

Hi I’m learning React and for practice I’m passing from simple html page to react component, I’m using react style component to apply the styles. In my classic css style sheet I have these rules for a input element: .input100 { font-family: Poppins-Medium; font-size: 16px; color: #333333; line-height: 1.2; display: block; width: 100%; height: 55px; […]

Why I get an error, when starting storybook

I get the error when try to start my Storybook. The things happened when I created new story for my component (before, my storybook worked properly): I got the error message about resolving my component from ‘components’ folder, moreover I got the error for all components that was created earlier and was tested. After, I […]

Adding google font link to styled components createGlobalStyle

The other css codes in GlobalStyle.js component are working except @import url(‘https://fonts.googleapis.com/css….. I imported GlobalStyle.js in App.js same as the screenshot. Could you note why this isn’t working? Source: React – Stack Overflow

Material UI 5: Classess defined by Styled Utility Not Working in Nested Elements

I was trying to upgrate material ui verion to 5(from 4). I was following documentation to migrate from makeStyles way to define classess to Styled API. But classNames defined in nested component/element is not taking styles defined by styled utility. import React from ‘react’; import {styled} from ‘@mui/material/styles’; import Box from "@mui/material/Box"; import theme from […]

Creating styled-component for component but don’t know type

I’m using the styled-components library, and am trying to style a component, but I don’t know the type. I’ve tried a bunch but I keep getting an error Error: Cannot create styled-component for component. Thanks in advance for any help! export const StyledSupply = styled.text ` textAlign: "center", fontSize: 30, fontWeight: "bold", color: "var(–accent-text)" `; […]

Adding "float: right" changes background color of container in React

I’m trying to render an image that is aligned on the right side of its container in React. This is what I have:. Here, StyledImage has two properties: width: 80% and float: right. The background color of the page is black without the float style added, but it turns white when I add it. How […]

Aligning Image to the Right w/ Styled Component ReactJS

I’m fairly new to ReactJS and am using styled components to display an image. The code I have in my App.js is <StyledImage src={mainimg} alt="hi"></StyledImage> which displays an image on the left side of the screen. My styling is export const StyledImage = styled.img` width: 80%; `; I’ve tried justify-content, alignitems… I’m not sure what […]

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.