I am looking to dynamically adjust the font size of a button based on the length of a passed-in prop. However, I can't use a dynamic width due to a custom animation applied to the component.
Here is my current code:
const checkLength = () => {
if (props.text.length > 7) {
return "15px";
} else {
return "17px";
}
};
const MyButton = styled.button`
font-size: 17px;
`
Although I attempted to incorporate the function into the styling like this, it does not recognize the function:
const MyButton = styled.button`
font-size: checkLength();
`