Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

With Bootstrap, how do I show radio inputs as buttons?

My form currently contains this code:

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>  <label for="opt-0"><input type="radio" name="opt" id="opt-0" checked>Option 0</label>  <label for="opt-1"><input type="radio" name="opt" id="opt-1">Option 1</label>  <label for="opt-2"><input type="radio" name="opt" id="opt-2">Option 2</label>

Instead of showing the radio buttons as radio buttons, I'd like to make them look like regular buttons, like this:

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>  <button class="btn btn-primary">Option 0</button>  <button class="btn btn-default">Option 1</button>  <button class="btn btn-default">Option 2</button>

I have radios and I want to make them look like toggleable buttons. How am I supposed to do that with Bootstrap?

like image 482
Likk Avatar asked Jan 07 '16 15:01

Likk


People also ask

What is the Bootstrap class for radio button?

A simple Bootstrap radio button example A group of three radio buttons is used that uses the radio class (by Bootstrap). The class is used in the div while input type radio is used inside the label tags.

Which method is used to display a radio button on the form?

Radio buttons are shown in radio groups to show a set of related options, only one of which can be selected. A radio button in HTML can be defined using the <input> tag.

How do I display radio buttons in HTML?

To create a radio button in HTML, use the <input> element with the type radio. This creates a single radio button that users can interact with: HTML.


Video Answer


1 Answers

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>      <div class="btn-group" data-toggle="buttons">        <label class="btn btn-primary">          <input type="radio" name="options" id="option1"> Option 1        </label>        <label class="btn btn-primary">          <input type="radio" name="options" id="option2"> Option 2        </label>        <label class="btn btn-primary">          <input type="radio" name="options" id="option3"> Option 3        </label>  </div>
like image 171
Shibu Thomas Avatar answered Oct 04 '22 05:10

Shibu Thomas