如何合并两个位于不同基础组件但具有相似样式的样式组件?

How to merge two styled-components which are in different base components but have similar styles?

我正在尝试将这两个样式组件合并为一个。

const CustomInput = styled.input`
    width: 150px;
    height: 100%; 
`;
const CustomTextarea = styled.textarea`
    width: 150px;
    height: 100%; 
`;

使用字符串插值:

const sharedCSS = css`
  width: 150px;
  height: 100%; 
`
const CustomInput = styled.Input`
  ${sharedCSS}
`
const CustomTextarea = styled.textarea`
  ${sharedCSS}
`