-
I have a component that is written with styled-components
-
Calling that component inside of new Styled component
-
Attach styles
Result: Styles are not applied
import {Button, Form, Input} from "antd";
import styled from "styled-components";
const {TextArea} = Input;
const Container = styled.div`
width: 768px;
`;
const StyledTextArea = styled(TextArea)`
resize: none;
`;
const StyledFormItem = styled(Form.Item)`
text-align: right;
`;
export default function ComentWriter() {
return (
<Container>
<Form layout="vertical">
<Form.Item
name="comment">
<StyledTextArea rows={3} />
</Form.Item>
<StyledFormItem>
<Button type="primary" htmlType="submit">
Wirte Comment
</Button>
</StyledFormItem>
</Form>
</Container>
);
}
What I want: TextArea’s resize is none
but my styled-component is overrided by antd’s css.
2
Answers
i have solved this problem to css variable.
Actually, it does apply to the TextArea Antd component. You can see it in your picture
resize:none. Due to the specificity in CSS, it has been overridden by the default styling of Antd. You can use!important
to make it apply regardless of specificity: