Search code examples
htmlcssmaterialize

radio button.checkbox not visible inside table in materialize css


How can I include radio button or checkbox inside the table?

<html>
    <head>
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
        <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
    </head>
    <body>
        <table>
            <thead><th>radio button</thead>
            <tbody><tr><td><input type="radio" value="r1"></td></tr></tbody>
        </table>
     </body>
</html>


Solution

  • As in F12 opacity:0 what means your radio is invisible:

    enter image description here

    As materialize doc you have to use radio as below with class="with-gap":

      <p>
        <label>
          <input class="with-gap" name="yourName" type="radio"/>
          <span>yout text</span>
        </label>
      </p>
    

    See working code

    <html>
    
      <head>
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
        <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
      </head>
    
      <body>
        <table>
          <thead>
            <th>radio button</thead>
          <tbody>
            <tr>
              <td>
                <p>
                  <label>
          <input class="with-gap" name="group3" type="radio" />
          <span>Red</span>
        </label>
                </p>
              </td>
            </tr>
          </tbody>
        </table>
      </body>
    
    </html>