Password Generator App using React, Typescript, SASS
Design comparison
Solution retrospective
Hi Community
Few questions on my solution
- How do I make sure that my React Components have their own scss file in their seperate folders instead of having to manage a
/sass
folder where I dump all my.scss
files.
What I mean is to have a folder structure like this
/Navbar
- Navbar.tsx
- Navbar.styles.scss
- Please look at the random password generation logic.
- Need some suggestions on Password strength indicator.
Community feedback
- @mukwende2000Posted over 1 year ago
You can use scoped css in react ot achieve styles unique to the component you want. You will have a 'Navbar.tsx' and then 'Navbar.module.scss'. And then in your component you import the styles like "import styles from './Navbar.module.scss'" you can call it whatever, the name styles is optional, you say "import classes from 'Navbar.module.scss'". To use the styles in your components you do it this way
function Navbar() { return ( <nav className={styles.nav}>contents</nav> ) }
the 'nav' in syles.nav refers to a class in your Navabar.module.scss, Which means you should have something like below in the file
.nav {your style rules}
so what ever class you have, you refer to it in the jsx by saying styles.the_name_of_the_class
0@pratik-pdwPosted over 1 year ago@mukwende2000
But then what if I want to use SASS variables defined at a place. Do I import those SASS variables every time ??
0@mukwende2000Posted over 1 year ago@pratik-pdw My knowledge of sass is very little, so i might not be the perfect person to answer that one.... Are you in the frontend mentor discord server?
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord