Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

MattB's avatar
Level 2

How do I pass prop to style object in vue Js

I'm trying to use an object to control the style of certain parts of an app as I'm trying to avoid inline styling. What how do I use Colour from props in the styling object below please?

 data: () => ({   
         props: ['header', 'questions', 'index', 'colour'],
         sectionScore: [],  
         styling: {
             borderLeft: '10px solid ${this.colour}'
         }         
     }),

I'm using the object in the main body with :style="styling".

0 likes
1 reply
tykus's avatar

Use backticks for String Interpolation.

             borderLeft: `10px solid ${this.colour}`

Please or to participate in this conversation.