Radio - 图1

Radio

Radio Layout

Radio layout is pretty simple:

  1. <!-- radio element -->
  2. <label class="radio">
  3. <!-- radio input -->
  4. <input type="radio">
  5. <!-- radio icon -->
  6. <i class="icon-radio"></i>
  7. </label>

Radio Group/List

To create Radio group/list we need to use List View with few additions:

  1. <div class="list">
  2. <ul>
  3. <!-- Single radio item -->
  4. <li>
  5. <label class="item-radio item-content">
  6. <!-- Radio input -->
  7. <input type="radio" name="my-radio" value="radio-1"/>
  8. <!-- Radio icon -->
  9. <i class="icon icon-radio"></i>
  10. <div class="item-inner">
  11. <!-- Radio Title -->
  12. <div class="item-title">Books</div>
  13. </div>
  14. </label>
  15. </li>
  16. <!-- Another radio item -->
  17. <li>
  18. <label class="item-radio item-content">
  19. <!-- Checked by default -->
  20. <input type="radio" name="my-radio" value="radio-2" checked/>
  21. <i class="icon icon-radio"></i>
  22. <div class="item-inner">
  23. <div class="item-title">Music</div>
  24. </div>
  25. </label>
  26. </li>
  27. ...
  28. </ul>
  29. </div>
  • item-content must be a <label> element with additional item-radio class
  • Radio input (<input type="radio">) must be a first child of item-content
  • Radio icon must be after radio input

Radio Icon Position

By default radio list item icon is displayed in the end of the list item in iOS theme, and in the beginning of the list item in MD and Aurora themes.

And it is possible to override this behavior to specify position of radio list item icon - in the beginning or in the end of the list item.

To do this, we need to add additional item-radio-icon-start or item-radio-icon-end class to item-radio:

  1. <!-- Additional "item-radio-icon-start" class will force radio icon to appear in the beginning of the list item for all themes -->
  2. <li>
  3. <!-- Additional "item-radio-icon-start" class -->
  4. <label class="item-radio item-radio-icon-start item-content">
  5. <!-- Radio input -->
  6. <input type="radio" name="my-radio" value="radio-1"/>
  7. <!-- Radio icon -->
  8. <i class="icon icon-radio"></i>
  9. <div class="item-inner">
  10. <!-- Radio Title -->
  11. <div class="item-title">Books</div>
  12. </div>
  13. </label>
  14. </li>
  15. <!-- Additional "item-radio-icon-end" class will force radio icon to appear in the end of the list item for all themes -->
  16. <li>
  17. <!-- Additional "item-radio-icon-end" class -->
  18. <label class="item-radio item-radio-icon-end item-content">
  19. <!-- Radio input -->
  20. <input type="radio" name="my-radio" value="radio-1"/>
  21. <!-- Radio icon -->
  22. <i class="icon icon-radio"></i>
  23. <div class="item-inner">
  24. <!-- Radio Title -->
  25. <div class="item-title">Books</div>
  26. </div>
  27. </label>
  28. </li>

CSS Variables

Below is the list of related CSS variables (CSS custom properties).

Note that commented variables are not specified by default and their values is what they fallback to in this case.

  1. :root {
  2. /*
  3. --f7-radio-active-color: var(--f7-theme-color);
  4. */
  5. --f7-radio-border-radius: 50%;
  6. }
  7. :root .theme-dark,
  8. :root.theme-dark {
  9. --f7-radio-inactive-color: rgba(255, 255, 255, 0.3);
  10. }
  11. .ios {
  12. --f7-radio-size: 22px;
  13. --f7-radio-border-width: 1px;
  14. --f7-radio-extra-margin: 0px;
  15. --f7-radio-inactive-color: #c7c7cc;
  16. }
  17. .md {
  18. --f7-radio-size: 20px;
  19. --f7-radio-border-width: 2px;
  20. --f7-radio-extra-margin: 22px;
  21. --f7-radio-inactive-color: #6d6d6d;
  22. }
  23. .aurora {
  24. --f7-radio-size: 16px;
  25. --f7-radio-border-width: 1px;
  26. --f7-radio-extra-margin: 0px;
  27. --f7-radio-inactive-color: #888;
  28. }

Examples

Inline

  1. <div class="block block-strong">
  2. <p>Lorem <label class="radio"><input type="radio" name="demo-radio-inline"><i class="icon-radio"></i></label> ipsum dolor sit amet, consectetur adipisicing elit. Alias beatae illo nihil aut eius commodi sint eveniet aliquid eligendi <label class="radio"><input type="radio" name="demo-radio-inline"><i class="icon-radio"></i></label> ad delectus impedit tempore nemo, enim vel praesentium consequatur nulla mollitia!</p>
  3. </div>

Radio Group

Icon in the beginning of the list item
  1. <div class="list">
  2. <ul>
  3. <li>
  4. <label class="item-radio item-radio-icon-start item-content">
  5. <input type="radio" name="demo-radio-start" value="Books" checked />
  6. <i class="icon icon-radio"></i>
  7. <div class="item-inner">
  8. <div class="item-title">Books</div>
  9. </div>
  10. </label>
  11. </li>
  12. <li>
  13. <label class="item-radio item-radio-icon-start item-content">
  14. <input type="radio" name="demo-radio-start" value="Movies"/>
  15. <i class="icon icon-radio"></i>
  16. <div class="item-inner">
  17. <div class="item-title">Movies</div>
  18. </div>
  19. </label>
  20. </li>
  21. <li>
  22. <label class="item-radio item-radio-icon-start item-content">
  23. <input type="radio" name="demo-radio-start" value="Food"/>
  24. <i class="icon icon-radio"></i>
  25. <div class="item-inner">
  26. <div class="item-title">Food</div>
  27. </div>
  28. </label>
  29. </li>
  30. <li>
  31. <label class="item-radio item-radio-icon-start item-content">
  32. <input type="radio" name="demo-radio-start" value="Drinks"/>
  33. <i class="icon icon-radio"></i>
  34. <div class="item-inner">
  35. <div class="item-title">Drinks</div>
  36. </div>
  37. </label>
  38. </li>
  39. </ul>
  40. </div>
Icon in the end of the list item
  1. <div class="list">
  2. <ul>
  3. <li>
  4. <label class="item-radio item-radio-icon-end item-content">
  5. <input type="radio" name="demo-radio-end" value="Books" checked />
  6. <i class="icon icon-radio"></i>
  7. <div class="item-inner">
  8. <div class="item-title">Books</div>
  9. </div>
  10. </label>
  11. </li>
  12. <li>
  13. <label class="item-radio item-radio-icon-end item-content">
  14. <input type="radio" name="demo-radio-end" value="Movies"/>
  15. <i class="icon icon-radio"></i>
  16. <div class="item-inner">
  17. <div class="item-title">Movies</div>
  18. </div>
  19. </label>
  20. </li>
  21. <li>
  22. <label class="item-radio item-radio-icon-end item-content">
  23. <input type="radio" name="demo-radio-end" value="Food"/>
  24. <i class="icon icon-radio"></i>
  25. <div class="item-inner">
  26. <div class="item-title">Food</div>
  27. </div>
  28. </label>
  29. </li>
  30. <li>
  31. <label class="item-radio item-radio-icon-end item-content">
  32. <input type="radio" name="demo-radio-end" value="Drinks"/>
  33. <i class="icon icon-radio"></i>
  34. <div class="item-inner">
  35. <div class="item-title">Drinks</div>
  36. </div>
  37. </label>
  38. </li>
  39. </ul>
  40. </div>

With Media Lists

  1. <div class="list media-list">
  2. <ul>
  3. <li>
  4. <label class="item-radio item-radio-icon-start item-content">
  5. <input type="radio" name="demo-media-radio" value="1" checked />
  6. <i class="icon icon-radio" checked></i>
  7. <div class="item-inner">
  8. <div class="item-title-row">
  9. <div class="item-title">Facebook</div>
  10. <div class="item-after">17:14</div>
  11. </div>
  12. <div class="item-subtitle">New messages from John Doe</div>
  13. <div class="item-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus.</div>
  14. </div>
  15. </label>
  16. </li>
  17. <li>
  18. <label class="item-radio item-radio-icon-start item-content">
  19. <input type="radio" name="demo-media-radio" value="2"/>
  20. <i class="icon icon-radio"></i>
  21. <div class="item-inner">
  22. <div class="item-title-row">
  23. <div class="item-title">John Doe (via Twitter)</div>
  24. <div class="item-after">17:11</div>
  25. </div>
  26. <div class="item-subtitle">John Doe (@_johndoe) mentioned you on Twitter!</div>
  27. <div class="item-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus.</div>
  28. </div>
  29. </label>
  30. </li>
  31. <li>
  32. <label class="item-radio item-radio-icon-start item-content">
  33. <input type="radio" name="demo-media-radio" value="3"/>
  34. <i class="icon icon-radio"></i>
  35. <div class="item-inner">
  36. <div class="item-title-row">
  37. <div class="item-title">Facebook</div>
  38. <div class="item-after">16:48</div>
  39. </div>
  40. <div class="item-subtitle">New messages from John Doe</div>
  41. <div class="item-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus.</div>
  42. </div>
  43. </label>
  44. </li>
  45. <li>
  46. <label class="item-radio item-radio-icon-start item-content">
  47. <input type="radio" name="demo-media-radio" value="4"/>
  48. <i class="icon icon-radio"></i>
  49. <div class="item-inner">
  50. <div class="item-title-row">
  51. <div class="item-title">John Doe (via Twitter)</div>
  52. <div class="item-after">15:32</div>
  53. </div>
  54. <div class="item-subtitle">John Doe (@_johndoe) mentioned you on Twitter!</div>
  55. <div class="item-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus.</div>
  56. </div>
  57. </label>
  58. </li>
  59. </ul>
  60. </div>

← Pull to Refresh

Range Slider →