1

I am using css module like this ,

.catTable{
  border:1px black solid;
}

in jsx

import styles from "../css/basic-styles.module.css";
return (
  <table className={styles.catTable}>
      <tr><td>test1</td><td>test2</td></tr>
      <tr><td>test3</td><td>test4</td></tr> 
  </table>);

It works well but I want to set the css for tr too

So I made the code like this below.

in normal css I can set like this,

.catTable{
    .catTr {
        border:1px pink solid;
    } 
     border:1px black solid;
 }

in jsx

import styles from "../css/basic-styles.module.css";
return (
  <table className={styles.catTable}>
      <tr className={styles.catTr><td>test1</td><td>test2</td></tr>
      <tr><td>test3</td><td>test4</td></tr> 
  </table>);

However border of tr doesn't work, where should I change?

2
  • Does React support CSS modules instead of SASS/LESS yet? Commented Jul 29, 2024 at 5:30
  • @whitebear, I am not sure, but in this code you write <tr className={styles.catTr> instead of <tr className={styles.catTr}>. Maybe this can resovle your error. Commented Jul 29, 2024 at 6:07

1 Answer 1

1

You can try applying styles directly without using any class like this

.catTable{
    tr {
        border:1px pink solid;
    } 
     border:1px black solid;
 }
Sign up to request clarification or add additional context in comments.

1 Comment

THank you very much I can nest the tag like this,

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.