radio.html 2.7 KB

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