Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap 4 Custom Checkbox Not Shown

i want to use bootstrap 4 custom control for checkbox, after reading the documentation i wrote this, but the checkbox is not shown, what am i doing wrong?

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="card-body"><label>Add Productc Varian for </label>
  <div class="form-group"><label for="formGroupExampleInput">Code</label><input type="text" class="form-control" placeholder="Enter Name"></div>
  <div class="form-group"><label for="formGroupExampleInput">Name</label><input type="text" class="form-control" placeholder="Enter Name"></div>
  <div class="form-group"><label for="formGroupExampleInput2">Description</label><textarea class="form-control" placeholder="Description"></textarea></div>
  <div class="form-group">
    <div class="custom-control custom-checkbox"><label for="formGroupExampleInput2">Default</label><input type="checkbox" class="custom-control-input" id="customControlValidation1"></div>
  </div>
  
<hr>
<div class="form-group">
  <div class="col-12"><button type="button" class="btn btn-default float-right">Add</button><button type="button" class="btn btn-danger float-right">Cancel</button></div>
</div>
</div>
like image 749
Matius Nugroho Aryanto Avatar asked Apr 22 '19 04:04

Matius Nugroho Aryanto


2 Answers

Just add the missed class custom-control-label for label. You just want to follow custom forms Bootstrap-v4 form for reference.

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />
<div class="card-body">
    <label>Add Productc Varian for </label>
    <div class="form-group">
        <label for="formGroupExampleInput">Code</label>
        <input type="text" class="form-control" placeholder="Enter Name">
    </div>
    <div class="form-group">
        <label for="formGroupExampleInput">Name</label>
        <input type="text" class="form-control" placeholder="Enter Name">
    </div>
    <div class="form-group">
        <label for="formGroupExampleInput2">Description</label>
        <textarea class="form-control" placeholder="Description"></textarea>
    </div>  
    <div class="form-group">
      <div class="custom-control custom-checkbox">
          <input type="checkbox" class="custom-control-input" id="customCheck1">
          <label class="custom-control-label" for="customCheck1">Default</label>
      </div>
    </div>
    <hr>
    <div class="form-group">
        <div class="col-12">
            <button type="button" class="btn btn-default float-right">Add</button>
            <button type="button" class="btn btn-danger float-right">Cancel</button>
        </div>
    </div>
</div>
like image 168
Saravana Avatar answered Nov 17 '22 21:11

Saravana


<!-- begin snippet: js hide: false console: true babel: false -->
 <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
    <div class="card-body"><label>Add Productc Varian for </label>
      <div class="form-group"><label for="formGroupExampleInput">Code</label><input type="text" class="form-control" placeholder="Enter Name"></div>
      <div class="form-group"><label for="formGroupExampleInput">Name</label><input type="text" class="form-control" placeholder="Enter Name"></div>
      <div class="form-group"><label for="formGroupExampleInput2">Description</label><textarea class="form-control" placeholder="Description"></textarea></div>
      <div class="form-group">
         <div class="custom-control custom-checkbox">
        <input type="checkbox" class="custom-control-input" id="customCheck" name="example1">
        <label class="custom-control-label" for="customCheck">Check this custom checkbox</label>
      </div>
      </div>
    <hr>
    <div class="form-group">
      <div class="col-12"><button type="button" class="btn btn-default float-right">Add</button><button type="button" class="btn btn-danger float-right">Cancel</button></div>
    </div>
    </div>
like image 27
Ashish Shah Avatar answered Nov 17 '22 21:11

Ashish Shah