[Vue] How to safely override Amplify built-in components via CSS?
See original GitHub issue** Which Category is your question related to? ** Amplify UI
** What AWS Services are you utilizing? ** Cognito
** Provide additional details e.g. code snippets **
Different from React I can’t pass a theme object to override drop-in components from Amplify for example - <amplify-authenticator>
After some digging I notice it creates a random class at build time .Form__formSection___3tqxz. While I can easily override the typography and color I’m quite sure this will break in upcoming updates.
Is there a safe way to do that or are you working on providing friendly classes one can go and override regardless of what framework (Angular/Vue/React) is using it?
Thanks a lot!
Issue Analytics
- State:
- Created 5 years ago
- Reactions:7
- Comments:12 (3 by maintainers)
Top Results From Across the Web
Customizing CSS - Vue - AWS Amplify Docs
You can control top level components directly using CSS. For instance, to control the layout of the amplify-authenticator , you can specify the...
Read more >How to override scoped styles in Vue components?
Since we always only have one root ( #app ) it's safe to use an ID in the rule-set. This easily overrides the...
Read more >Vue.js - Scoped Styles vs CSS Modules - Netguru
Scoped CSS vs CSS Modules in Vue.js application. ... conflicting styles that override each other or that implicitly cascade down to elements ......
Read more >Styling Vue components with CSS - Learn web development
You can include external CSS files and apply them globally to your app. Let's look at how this is done. To start with,...
Read more >8 New features in the Amplify Authenticator for web you ... - AWS
All examples are in React, however you can use them with Vue and ... this by adding a new formFields prop to your...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@heitorlessa @jordanranz
I created #2470 shortly before you posted this very similar question. I poked around a bit and found a workaround that should at least let you theme the components:
In your App.vue <style> section insert this code and define the colors how you see fit. I changed the built-in Amazon orange to a dark green as an example:
What you’re doing is overriding the CSS variables which control the theme used by Amplify. Check out https://github.com/aws-amplify/amplify-js/blob/master/packages/amplify-ui/src/Theme.css for more overridable CSS.
I would consider this a hack but it will work for my needs for now… this may not be forwards compatible if the variable names change in Theme.css. I don’t think this issue should be closed but hopefully this workaround will help someone out there in the meantime.
Besides using the CSS variables @cliffordh pointed out, you may also come across a moment where you need to remove paddings or change dimensions.
I achieved this by passing an additional class in the route to the authenticator: in
router.js:Then on my
App.vuesytle:I hope this helps someone! 😃