0

I've got the following variables:

let backgroundColour = 'bg-green-100';
let textColour = 'text-green-700';

And I am trying to pass this class into my ClassName within my render();

  <div className="{backgroundColour} p-5 max-w-md w-full rounded mb-5">
            <div className="flex justify-between">
                <div className="flex space-x-3">
                    <div className="{textColour} flex-1 leading-tight text-sm font-medium">
                        {props.success}
                    </div>
                </div>
            </div>
        </div>

The following is adding {backgroundColour} into the html markup instead of returning the value of the var. Any help on how to get this to correct pull through would be appreciated.

2 Answers 2

2

Use this:

  <div className={`${backgroundColour} p-5 max-w-md w-full rounded mb-5`}>
      <div className="flex justify-between">
          <div className="flex space-x-3">
              <div className={`${textColour} flex-1 leading-tight text-sm font-medium`}>
                  {props.success}
              </div>
          </div>
      </div>
  </div>
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, I've just managed to resolve it :)
Great, approve the answer would be helpful for future readers
0

I've managed to resolve the error using the following:

<div className={"p-5 max-w-md w-full rounded mb-5 " + backgroundColour}>
</div>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.