radio.html 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. ---
  2. title: Radio button
  3. layout: documentation
  4. doc-tab: form
  5. doc-subtab: radio
  6. ---
  7. {% capture radio_example %}
  8. <div class="control">
  9. <label class="radio">
  10. <input type="radio" name="answer">
  11. Yes
  12. </label>
  13. <label class="radio">
  14. <input type="radio" name="answer">
  15. No
  16. </label>
  17. </div>
  18. {% endcapture %}
  19. {% capture radio_default_example %}
  20. <div class="control">
  21. <label class="radio">
  22. <input type="radio" name="foobar">
  23. Foo
  24. </label>
  25. <label class="radio">
  26. <input type="radio" name="foobar" checked>
  27. Bar
  28. </label>
  29. </div>
  30. {% endcapture %}
  31. {% capture radio_disabled_example %}
  32. <div class="control">
  33. <label class="radio">
  34. <input type="radio" name="rsvp">
  35. Going
  36. </label>
  37. <label class="radio">
  38. <input type="radio" name="rsvp">
  39. Not going
  40. </label>
  41. <label class="radio" disabled>
  42. <input type="radio" name="rsvp" disabled>
  43. Maybe
  44. </label>
  45. </div>
  46. {% endcapture %}
  47. {% include subnav-form.html %}
  48. <section class="section">
  49. <div class="container">
  50. <h1 class="title">Radio</h1>
  51. <h2 class="subtitle">
  52. The mutually exclusive <strong>radio buttons</strong> in their native format
  53. </h2>
  54. {%
  55. include meta.html
  56. colors=false
  57. sizes=false
  58. variables=false
  59. %}
  60. <hr>
  61. <div class="content">
  62. <p>
  63. 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.
  64. </p>
  65. <p>
  66. Make sure the linked radio buttons have the <strong>same value</strong> for their <code>name</code> HTML attribute.
  67. </p>
  68. </div>
  69. <div class="columns">
  70. <div class="column is-half">
  71. {{radio_example}}
  72. </div>
  73. <div class="column is-half highlight-full">
  74. {% highlight html %}{{radio_example}}{% endhighlight %}
  75. </div>
  76. </div>
  77. <div class="content">
  78. <p>
  79. 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.
  80. </p>
  81. </div>
  82. <div class="columns">
  83. <div class="column is-half">
  84. {{radio_default_example}}
  85. </div>
  86. <div class="column is-half highlight-full">
  87. {% highlight html %}{{radio_default_example}}{% endhighlight %}
  88. </div>
  89. </div>
  90. <div class="content">
  91. <p>
  92. 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>.
  93. </p>
  94. </div>
  95. <div class="columns">
  96. <div class="column is-half">
  97. {{radio_disabled_example}}
  98. </div>
  99. <div class="column is-half highlight-full">
  100. {% highlight html %}{{radio_disabled_example}}{% endhighlight %}
  101. </div>
  102. </div>
  103. </div>
  104. </section>