Permiten selecionar de entre 2 a 5 opciones.
La base es un elemento con
class="md-segmented-button".
Puedes usar
type="radio"
para seleccionar una sola opción para un mismo valor del atributo
name.
Puedes usar
type="checkbox"
para seleccionar varias opciones con un mismo valor del atributo
name.
| 1 | <!DOCTYPE html> |
| 2 | <html lang="es" class="light dark"> |
| 3 | |
| 4 | <head> |
| 5 | |
| 6 | <meta charset="UTF-8"> |
| 7 | <title>Botón segmentado - PWA con MD</title> |
| 8 | |
| 9 | <script src="js/registraServiceWorker.js"></script> |
| 10 | |
| 11 | <meta name="viewport" content="width=device-width"> |
| 12 | <meta name="theme-color" content="#fffbfe"> |
| 13 | <link rel="icon" sizes="32x32" href="favicon.ico"> |
| 14 | <link rel="manifest" href="site.webmanifest"> |
| 15 | <script src="ungap/custom-elements.js"></script> |
| 16 | |
| 17 | <script type="module" src="js/configura.js"></script> |
| 18 | <link rel="stylesheet" href="css/estilos.css"> |
| 19 | <link rel="stylesheet" href="css/transicion_completa.css"> |
| 20 | |
| 21 | </head> |
| 22 | |
| 23 | <body> |
| 24 | |
| 25 | <md-top-app-bar headline="headline"> |
| 26 | |
| 27 | <h1>Segmentado</h1> |
| 28 | |
| 29 | <button is="md-menu-button" slot="navigation"></button> |
| 30 | |
| 31 | </md-top-app-bar> |
| 32 | |
| 33 | <h1 id="headline">Botón segmentado</h1> |
| 34 | |
| 35 | <main> |
| 36 | |
| 37 | <p class="md-segmented-button"> |
| 38 | |
| 39 | <input id="bueno" type="radio" name="estado" checked value="2"> |
| 40 | <label for="bueno"> |
| 41 | <span class="material-symbols-outlined">done</span> |
| 42 | Bueno |
| 43 | </label> |
| 44 | |
| 45 | <input id="intermedio" type="radio" name="estado" value="1"> |
| 46 | <label for="intermedio"> |
| 47 | <span class="material-symbols-outlined">done</span> |
| 48 | Intermedio |
| 49 | </label> |
| 50 | |
| 51 | <input id="malo" type="radio" name="estado" value="0"> |
| 52 | <label for="malo"> |
| 53 | <span class="material-symbols-outlined">done</span> |
| 54 | Malo |
| 55 | </label> |
| 56 | |
| 57 | </p> |
| 58 | |
| 59 | </main> |
| 60 | |
| 61 | <nav-drw></nav-drw> |
| 62 | |
| 63 | </body> |
| 64 | |
| 65 | </html> |
Los botones segmentados de Material Design están defnidos en https://m3.material.io/components/segmented-buttons/overview.