Styling in Vue is a breeze.
It's most common to have a <style>
tag last/at-the-bottom of SCFs.
Adding a scoped attribute to the <style>
limits the css to the component only, meaning that the styles don't cascade to child elements.
Children components which have the class .container
won't have the background color property applied despite.
We can use both style tags to get the best of both worlds.
If we want to target style the child elements/components we can use deep selectors.
It's possible to define styles as a module. Doing so helps to prevent name collisions of classes.
It's possible to make component state apply CSS styles as well.
In this case the color
state variable defines the property to a CSS class which ultimately styles the template/component.
It's possible to use POJO's & JS expressions together to produce dynamic styling as well.
Note that we have to wrap the expression with strings.