styled-components

React — Passing props with styled-components

感情迁移 提交于 2020-04-08 08:48:13
问题 I just read in the styled-components documentation that the following is wrong and it will affect render times. If that is the case, how can I refactor the code and use the required props to create a dynamic style? Thank you in advance. Tab component import React from 'react' import styled from 'styled-components' const Tab = ({ onClick, isSelected, children }) => { const TabWrapper = styled.li` display: flex; align-items: center; justify-content: center; padding: 100px; margin: 1px; font

Styled Component Semantic kit ( Form . Input )

半城伤御伤魂 提交于 2020-03-22 08:23:30
问题 Hello I would like to know how I could change css with the styled component of the form. semantic input I need something like this on hoover: But I can't change the background color of the input and also the border color in both default and hover: export const FormCustom = styled(Form)` &&& { background: #000; } ` export const FormInput = styled(Form.Input)` &&& { color: red; background: transparent; } ` tried but to no avail export const FormInput = styled(Form.Input)` &&& { color: red;

Import css files from node modules in Next JS?

一世执手 提交于 2020-03-21 16:10:43
问题 I am very new to next.js . Using it for the server side rendering of my application. According to the documentation you can import css files from a static folder which should be in root directory but i want to import css from node_modules because i have extended bootstrap and created my own package. 回答1: This is the solution you are probably looking for: 3 simple steps: Install next-css plugin: npm install --save @zeit/next-css Create in your root directory next.config.js with the following

Import css files from node modules in Next JS?

早过忘川 提交于 2020-03-21 16:10:08
问题 I am very new to next.js . Using it for the server side rendering of my application. According to the documentation you can import css files from a static folder which should be in root directory but i want to import css from node_modules because i have extended bootstrap and created my own package. 回答1: This is the solution you are probably looking for: 3 simple steps: Install next-css plugin: npm install --save @zeit/next-css Create in your root directory next.config.js with the following

Impossible to edit styles in Chrome?

偶尔善良 提交于 2020-02-18 00:59:45
问题 Since I've implemented server side rendering and managing the styles with styled-components , Im unable to edit styles in Chrome Dev Tools. The styles in devtools become italic and theres no checkbox to turn off/on specified style. It works properly in Mozilla. But why not in Chrome? Any ideas why does it happen? Thanks. Note : It happens in production. 回答1: I think you're probably seeing the styles injected via "speedy mode" in production. This uses a special DOM API that Chrome DevTools

toggle button / button with icon and text /

雨燕双飞 提交于 2020-01-25 10:15:27
问题 I have a menu that opens has a button with 100% witdh with text and icon and when closed it has only the icon but I still don't know how I will do this so when my state is closed show only the icon and not the text Also my icon is not in the center when it is closed. code with my state : function Menu() { const [open, setOpen] = useState(true); // declare new state variable "open" with setter const handleClick = e => { e.preventDefault(); setOpen(!open); }; return ( <ContainerGrid style={

toggle button / button with icon and text /

孤人 提交于 2020-01-25 10:15:11
问题 I have a menu that opens has a button with 100% witdh with text and icon and when closed it has only the icon but I still don't know how I will do this so when my state is closed show only the icon and not the text Also my icon is not in the center when it is closed. code with my state : function Menu() { const [open, setOpen] = useState(true); // declare new state variable "open" with setter const handleClick = e => { e.preventDefault(); setOpen(!open); }; return ( <ContainerGrid style={

React Styled Components - How to access raw html

走远了吗. 提交于 2020-01-24 03:51:06
问题 I have a ref on a component I am converting over to a styled component in my app. The ref is used to access the offsetHeight and scrollHeight properties on the raw html element of the component. Once I switched this component to a styled component, the ref now points to the styled component instead of the raw html element, and I'm unsure how to reference the base element. Can this be done? example: const TextArea = styled.textarea` display: block; margin: 0 0 0 18%; padding: 4px 6px; width:

Migrating to Styled-Components with global SASS variables in React

泄露秘密 提交于 2020-01-22 23:07:26
问题 I'm trying to slowly introduce Styled-Components into my existing codebase which relies heavily on global SASS variables (partials imported into a main.scss ). How do I reference the SCSS variables? The following doesn't work: import React from 'react'; import styled from 'styled-components'; const Button = styled.button` background-color: $color-blue; `; export default Button; Am I approaching this from the wrong way? 回答1: Variables play a very important role in .scss or .sass , but the

Migrating to Styled-Components with global SASS variables in React

会有一股神秘感。 提交于 2020-01-22 23:06:34
问题 I'm trying to slowly introduce Styled-Components into my existing codebase which relies heavily on global SASS variables (partials imported into a main.scss ). How do I reference the SCSS variables? The following doesn't work: import React from 'react'; import styled from 'styled-components'; const Button = styled.button` background-color: $color-blue; `; export default Button; Am I approaching this from the wrong way? 回答1: Variables play a very important role in .scss or .sass , but the