form-image-check.mdx 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. ---
  2. title: Image check
  3. summary: The image check is a great way to make your form more user-friendly and engaging. You can use the image check to create a visually appealing form that will help users make decisions quickly and easily.
  4. description: Add visual appeal to forms with images.
  5. ---
  6. ## Default markup
  7. To build an image check, you need to use the `.form-imagecheck` class and the `.form-imagecheck-input` class for the input element. You can also use the `.form-imagecheck-figure` class to style the image and the `.form-imagecheck-image` class to style the image itself.
  8. ```html
  9. <label class="form-imagecheck">
  10. <input name="..." type="checkbox" value="" class="form-imagecheck-input" checked />
  11. <span class="form-imagecheck-figure">
  12. <img src="..." alt="" class="form-imagecheck-image" />
  13. </span>
  14. </label>
  15. ```
  16. Look at the examples below to see how the image check works:
  17. ```html example centered columns="2" height="15rem"
  18. <div class="mb-3">
  19. <label class="form-label">Image Check</label>
  20. <div class="row g-2">
  21. <div class="col-3">
  22. <label class="form-imagecheck">
  23. <input name="image" type="checkbox" value="1" class="form-imagecheck-input" />
  24. <span class="form-imagecheck-figure">
  25. <img src="/samples/photos/everything-you-need-to-work-from-your-bed-2.jpg" alt="" class="form-imagecheck-image" />
  26. </span>
  27. </label>
  28. </div>
  29. <div class="col-3">
  30. <label class="form-imagecheck">
  31. <input name="image" type="checkbox" value="2" class="form-imagecheck-input" checked />
  32. <span class="form-imagecheck-figure">
  33. <img src="/samples/photos/color-palette-guide-sample-colors-catalog-.jpg" alt="" class="form-imagecheck-image" />
  34. </span>
  35. </label>
  36. </div>
  37. <div class="col-3">
  38. <label class="form-imagecheck">
  39. <input name="image" type="checkbox" value="3" class="form-imagecheck-input" />
  40. <span class="form-imagecheck-figure">
  41. <img src="/samples/photos/woman-read-book-and-drink-coffee-2.jpg" alt="" class="form-imagecheck-image" />
  42. </span>
  43. </label>
  44. </div>
  45. <div class="col-3">
  46. <label class="form-imagecheck">
  47. <input name="image" type="checkbox" value="4" class="form-imagecheck-input" checked />
  48. <span class="form-imagecheck-figure">
  49. <img src="/samples/photos/stylish-workspace-with-macbook-pro-2.jpg" alt="" class="form-imagecheck-image" />
  50. </span>
  51. </label>
  52. </div>
  53. </div>
  54. </div>
  55. ```
  56. ## Radio buttons
  57. If you want to use the image check as a radio button, you can change the input type to `radio`.
  58. ```html example centered columns="2" height="15rem"
  59. <div class="mb-3">
  60. <label class="form-label">Image Check Radio</label>
  61. <div class="row g-2">
  62. <div class="col-3">
  63. <label class="form-imagecheck mb-2">
  64. <input name="image" type="radio" value="1" class="form-imagecheck-input" />
  65. <span class="form-imagecheck-figure">
  66. <img src="/samples/photos/woman-drinking-hot-tea-in-her-home-office.jpg" alt="" class="form-imagecheck-image" />
  67. </span>
  68. </label>
  69. </div>
  70. <div class="col-3">
  71. <label class="form-imagecheck mb-2">
  72. <input name="image" type="radio" value="2" class="form-imagecheck-input" checked />
  73. <span class="form-imagecheck-figure">
  74. <img src="/samples/photos/young-woman-sitting-on-the-sofa-and-working-on-her-laptop-3.jpg" alt="" class="form-imagecheck-image" />
  75. </span>
  76. </label>
  77. </div>
  78. <div class="col-3">
  79. <label class="form-imagecheck mb-2">
  80. <input name="image" type="radio" value="3" class="form-imagecheck-input" />
  81. <span class="form-imagecheck-figure">
  82. <img src="/samples/photos/beautiful-blonde-woman-relaxing-with-a-can-of-coke-on-a-tree-stump-by-the-beach.jpg" alt="" class="form-imagecheck-image" />
  83. </span>
  84. </label>
  85. </div>
  86. <div class="col-3">
  87. <label class="form-imagecheck mb-2">
  88. <input name="image" type="radio" value="4" class="form-imagecheck-input" checked />
  89. <span class="form-imagecheck-figure">
  90. <img src="/samples/photos/book-on-the-grass.jpg" alt="" class="form-imagecheck-image" />
  91. </span>
  92. </label>
  93. </div>
  94. </div>
  95. </div>
  96. ```
  97. ```html
  98. <label class="form-imagecheck">
  99. <input name="..." type="radio" value="1" class="form-imagecheck-input" />
  100. <span class="form-imagecheck-figure">
  101. <img src="..." alt="" class="form-imagecheck-image" />
  102. </span>
  103. </label>
  104. ```
  105. ## Avatars
  106. If you want to use the image check with avatars, you can use the `.avatar` instead of the image.
  107. ```html example centered columns={2} height="15rem"
  108. <div class="mb-3">
  109. <label class="form-label">Person Check</label>
  110. <div class="row g-2">
  111. <div class="col-auto">
  112. <label class="form-imagecheck mb-2">
  113. <input name="image" type="checkbox" value="1" class="form-imagecheck-input" />
  114. <span class="form-imagecheck-figure">
  115. <span class="form-imagecheck-image">
  116. <span class="avatar avatar-xl" style="background-image: url(/samples/avatars/057f.jpg)"></span>
  117. </span>
  118. </span>
  119. </label>
  120. </div>
  121. <div class="col-auto">
  122. <label class="form-imagecheck mb-2">
  123. <input name="image" type="checkbox" value="2" class="form-imagecheck-input" checked />
  124. <span class="form-imagecheck-figure">
  125. <span class="form-imagecheck-image">
  126. <span class="avatar avatar-xl">HS</span>
  127. </span>
  128. </span>
  129. </label>
  130. </div>
  131. <div class="col-auto">
  132. <label class="form-imagecheck mb-2">
  133. <input name="image" type="checkbox" value="3" class="form-imagecheck-input" />
  134. <span class="form-imagecheck-figure">
  135. <span class="form-imagecheck-image">
  136. <span class="avatar avatar-xl" style="background-image: url(/samples/avatars/062m.jpg)"></span>
  137. </span>
  138. </span>
  139. </label>
  140. </div>
  141. <div class="col-auto">
  142. <label class="form-imagecheck mb-2">
  143. <input name="image" type="checkbox" value="4" class="form-imagecheck-input" checked />
  144. <span class="form-imagecheck-figure">
  145. <span class="form-imagecheck-image">
  146. <span class="avatar avatar-xl" style="background-image: url(/samples/avatars/070m.jpg)"></span>
  147. </span>
  148. </span>
  149. </label>
  150. </div>
  151. </div>
  152. </div>
  153. ```
  154. ```html
  155. <label class="form-imagecheck">
  156. <input name="..." type="checkbox" value="..." class="form-imagecheck-input" />
  157. <span class="form-imagecheck-figure">
  158. <span class="form-imagecheck-image">
  159. <span class="avatar avatar-md" style="background-image: url(...)"></span>
  160. </span>
  161. </span>
  162. </label>
  163. ```