radio.html 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. ---
  2. title: Radio button
  3. layout: documentation
  4. doc-tab: form
  5. doc-subtab: radio
  6. breadcrumb:
  7. - home
  8. - documentation
  9. - form
  10. - form-radio
  11. meta:
  12. colors: false
  13. sizes: false
  14. variables: false
  15. ---
  16. {% capture radio_example %}
  17. <div class="control">
  18. <label class="radio">
  19. <input type="radio" name="answer">
  20. Yes
  21. </label>
  22. <label class="radio">
  23. <input type="radio" name="answer">
  24. No
  25. </label>
  26. </div>
  27. {% endcapture %}
  28. {% capture radio_default_example %}
  29. <div class="control">
  30. <label class="radio">
  31. <input type="radio" name="foobar">
  32. Foo
  33. </label>
  34. <label class="radio">
  35. <input type="radio" name="foobar" checked>
  36. Bar
  37. </label>
  38. </div>
  39. {% endcapture %}
  40. {% capture radio_disabled_example %}
  41. <div class="control">
  42. <label class="radio">
  43. <input type="radio" name="rsvp">
  44. Going
  45. </label>
  46. <label class="radio">
  47. <input type="radio" name="rsvp">
  48. Not going
  49. </label>
  50. <label class="radio" disabled>
  51. <input type="radio" name="rsvp" disabled>
  52. Maybe
  53. </label>
  54. </div>
  55. {% endcapture %}
  56. <div class="content">
  57. <p>
  58. The <code>radio</code> class is a simple wrapper around the <code>&lt;input type="radio"&gt;</code> HTML elements. It is intentionally not styled, to preserve cross-browser compatibility and the user experience.
  59. </p>
  60. <p>
  61. Make sure the linked radio buttons have the <strong>same value</strong> for their <code>name</code> HTML attribute.
  62. </p>
  63. </div>
  64. <div class="columns">
  65. <div class="column is-half">
  66. {{radio_example}}
  67. </div>
  68. <div class="column is-half highlight-full">
  69. {% highlight html %}{{radio_example}}{% endhighlight %}
  70. </div>
  71. </div>
  72. <div class="content">
  73. <p>
  74. You can check a radio button by <strong>default</strong> by adding the <code>checked</code> HTML attribute to the <code>&lt;input&gt;</code> element.
  75. </p>
  76. </div>
  77. <div class="columns">
  78. <div class="column is-half">
  79. {{radio_default_example}}
  80. </div>
  81. <div class="column is-half highlight-full">
  82. {% highlight html %}{{radio_default_example}}{% endhighlight %}
  83. </div>
  84. </div>
  85. <div class="content">
  86. <p>
  87. You can add <strong>disable</strong> a radio button by adding the <code>disabled</code> HTML attribute to both the <code>&lt;label&gt;</code> and the <code>&lt;input&gt;</code>.
  88. </p>
  89. </div>
  90. <div class="columns">
  91. <div class="column is-half">
  92. {{radio_disabled_example}}
  93. </div>
  94. <div class="column is-half highlight-full">
  95. {% highlight html %}{{radio_disabled_example}}{% endhighlight %}
  96. </div>
  97. </div>