Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

md-checkbox : the size of checkbox without a label is wider than it should be #2175

Closed
TalPasi opened this issue Apr 6, 2015 · 1 comment
Assignees
Milestone

Comments

@TalPasi
Copy link

TalPasi commented Apr 6, 2015

When placing a checkbox inside a table cell, I don't want it to have a label, since the header is providing the textual context for it.

The problem is that the label has properties in its css, that makes the checkbox to be wider that it should be, so when I am centering the content of the cell, the checkbox is not entirely centered.

md-checkbox .md-label {
border: 1px dotted transparent;
display: inline-block;
margin-left: 10px;
}

please check the following following for a demo of the problem: codepen

@marcysutton marcysutton added this to the 0.10.0 milestone Apr 6, 2015
@marcysutton marcysutton self-assigned this Apr 6, 2015
@marcysutton marcysutton modified the milestones: 0.9.0, 0.10.0 Apr 15, 2015
@marcysutton
Copy link
Contributor

@TalPasi fixed this by only adding the margin if a visual label is present–it was an easy hook to differentiate between checkboxes with text vs. without.

One note: your checkbox in the table cell still needs a label for accessibility. You can do this one of two ways:

Add aria-label to the checkbox

<table>
    <th>Selected</th>
    <tr>
      <td>
         <md-checkbox aria-label="Selected"></md-checkbox>
      </td>
      </tr>
  </table>

Add aria-labelledby to the checkbox pointing to a table header ID

<table>
    <th id="selectedHeader">Selected</th>
    <tr>
      <td>
         <md-checkbox aria-labelledby="selectedHeader"></md-checkbox>
      </td>
      </tr>
  </table>

If the second version logs a warning to the console, we should open an issue and fix it since it's a valid approach to labeling.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants