Radios
Mostrar parámetros
Parámetros del componente
params:
- name: fieldset
type: object
required: false
description: Options for the fieldset component (e.g. legend).
isComponent: true
- name: hint
type: object
required: false
description: Options for the hint component (e.g. text).
isComponent: true
- name: errorMessage
type: object
required: false
description: Options for the error message component. The error message component will not display if you use a falsy value for `errorMessage`, for example `false` or `null`.
isComponent: true
- name: formGroup
type: object
required: false
description: Options for the form-group wrapper
params:
- name: classes
type: string
required: false
description: Classes to add to the form group (e.g. to show error state for the whole group)
- name: idPrefix
type: string
required: false
description: String to prefix id for each checkbox item if no id is specified on each item. If `idPrefix` is not passed, fallback to using the name attribute instead.
- name: name
type: string
required: true
description: Name attribute for each radio item.
- name: items
type: array
required: true
description: Array of radio items objects.
params:
- name: text
type: string
required: true
description: If `html` is set, this is not required. Text to use within each radio item label. If `html` is provided, the `text` argument will be ignored.
- name: html
type: string
required: true
description: If `text` is set, this is not required. HTML to use within each radio item label. If `html` is provided, the `text` argument will be ignored.
- name: id
type: string
required: false
description: Specific id attribute for the radio item. If omitted, then `idPrefix` string will be applied.
- name: value
type: string
required: true
description: Value for the radio input.
- name: label
type: object
required: false
description: Provide attributes and classes to each radio item label.
isComponent: true
- name: hint
type: object
required: false
description: Provide hint to each checkbox item.
isComponent: true
- name: divider
type: string
required: false
description: Divider text to separate radio items, for example the text "or".
- name: checked
type: boolean
required: false
description: If true, radio will be checked.
- name: conditional
type: string
required: false
description: If true, content provided will be revealed when the item is checked.
- name: conditional.html
type: html
required: false
description: Provide content for the conditional reveal.
- name: disabled
type: boolean
required: false
description: If true, radio will be disabled.
- name: classes
type: string
required: false
description: Classes to add to the item.
- name: attributes
type: object
required: false
description: HTML attributes (for example data attributes) to add to the radio input tag.
- name: hasDividers
type: boolean
required: false
description: With hasDividers equal to true, the items have an horizontal border to visually separate items.
- name: classes
type: string
required: false
description: Classes to add to the radio container.
- name: attributes
type: object
required: false
description: HTML attributes (for example data attributes) to add to the radio input tag.
Por defecto #
Mostrar códigodel ejemplo: Por defecto
Contenido
Nunjucks macro
{% from "components/radios/_macro.radios.njk" import componentRadios %}
{{ componentRadios({
"idPrefix": "default",
"name": "por defecto",
"fieldset": {
"legend": {
"text": "¿Quieres que te contactemos por correo electrónico?"
}
},
"hint": {
"text": "Sólo puedes seleccionar un elemento."
},
"items": [
{
"value": "si",
"text": "Si"
},
{
"value": "no",
"text": "No",
"checked": true
}
]
}) }}
HTML
<!-- radios -->
<div class="c-form-group">
<!-- fieldset -->
<fieldset aria-describedby="default-hint">
<legend class="font-bold">
¿Quieres que te contactemos por correo electrónico?
</legend>
<!-- hint -->
<p id="default-hint" class="block text-neutral-dark">Sólo puedes seleccionar un elemento.</p>
<!-- /hint -->
<div class="c-radios" data-module="c-radios">
<div class=" c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="default" name="por defecto" type="radio" value="si">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="default">Si</label>
<!-- /label -->
</div>
</div>
</div>
</div>
<div class=" c-radios__conditional-active ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="default-2" name="por defecto" type="radio" value="no" checked>
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="default-2">No</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</div>
</fieldset>
<!-- /fieldset -->
</div>
<!-- /radios -->
En línea #
Mostrar códigodel ejemplo: En línea
Contenido
Nunjucks macro
{% from "components/radios/_macro.radios.njk" import componentRadios %}
{{ componentRadios({
"idPrefix": "inline",
"classes": "flex",
"name": "inline",
"fieldset": {
"legend": {
"text": "¿Quieres que te contactemos por correo electrónico?"
}
},
"hint": {
"text": "Sólo puedes seleccionar un elemento."
},
"items": [
{
"value": "si",
"text": "Si",
"classes": "mr-sm"
},
{
"value": "no",
"text": "No",
"classes": "mr-sm",
"checked": true
}
]
}) }}
HTML
<!-- radios -->
<div class="c-form-group">
<!-- fieldset -->
<fieldset aria-describedby="inline-hint">
<legend class="font-bold">
¿Quieres que te contactemos por correo electrónico?
</legend>
<!-- hint -->
<p id="inline-hint" class="block text-neutral-dark">Sólo puedes seleccionar un elemento.</p>
<!-- /hint -->
<div class="c-radios flex" data-module="c-radios">
<div class=" mr-sm c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="inline" name="inline" type="radio" value="si">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="inline">Si</label>
<!-- /label -->
</div>
</div>
</div>
</div>
<div class=" mr-sm c-radios__conditional-active ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="inline-2" name="inline" type="radio" value="no" checked>
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="inline-2">No</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</div>
</fieldset>
<!-- /fieldset -->
</div>
<!-- /radios -->
Con deshabilitado #
Mostrar códigodel ejemplo: Con deshabilitado
Contenido
Nunjucks macro
{% from "components/radios/_macro.radios.njk" import componentRadios %}
{{ componentRadios({
"idPrefix": "example-disabled",
"name": "example-disabled",
"fieldset": {
"legend": {
"text": "¿Quieres que te contactemos por correo electrónico?"
}
},
"hint": {
"text": "Sólo puedes seleccionar un elemento."
},
"items": [
{
"value": "si",
"text": "Si",
"disabled": true,
"checked": true
},
{
"value": "no",
"text": "No",
"disabled": true
}
]
}) }}
HTML
<!-- radios -->
<div class="c-form-group">
<!-- fieldset -->
<fieldset aria-describedby="example-disabled-hint">
<legend class="font-bold">
¿Quieres que te contactemos por correo electrónico?
</legend>
<!-- hint -->
<p id="example-disabled-hint" class="block text-neutral-dark">Sólo puedes seleccionar un elemento.</p>
<!-- /hint -->
<div class="c-radios" data-module="c-radios">
<div class=" c-radios__conditional-active ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="example-disabled" name="example-disabled" type="radio" value="si" checked disabled>
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="example-disabled">Si</label>
<!-- /label -->
</div>
</div>
</div>
</div>
<div class=" c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="example-disabled-2" name="example-disabled" type="radio" value="no" disabled>
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="example-disabled-2">No</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</div>
</fieldset>
<!-- /fieldset -->
</div>
<!-- /radios -->
Con un legend como encabezado #
Usa el parámetro "heading"
para añadir un encabezado asociado al componente. Usa el parámetro "headingLevel"
para establecer el nivel del encabezado. Por ejemplo: "headingLevel": 3
creará un encabezado <h3>
.
Mostrar códigodel ejemplo: Con un legend como encabezado
Contenido
Nunjucks macro
{% from "components/radios/_macro.radios.njk" import componentRadios %}
{{ componentRadios({
"idPrefix": "legend-as-page-heading",
"name": "legend-as-page-heading",
"fieldset": {
"legend": {
"text": "¿Cómo prefieres que te contactemos?",
"classes": "c-h2",
"isPageHeading": true
},
"headingLevel": 2
},
"hint": {
"text": "Selecciona una de las opciones."
},
"items": [
{
"value": "part-2",
"text": "Por correo electrónico",
"hint": {
"text": "Asegúrate de que nuestros correos no lleguen a la bandeja de spam."
}
},
{
"value": "part-3",
"text": "Por correo postal",
"hint": {
"text": "Asegúrate de haber introducido correctamente tu dirección."
}
}
]
}) }}
HTML
<!-- radios -->
<div class="c-form-group">
<!-- fieldset -->
<fieldset aria-describedby="legend-as-page-heading-hint">
<legend class="c-h2">
<h2>
¿Cómo prefieres que te contactemos?
</h2>
</legend>
<!-- hint -->
<p id="legend-as-page-heading-hint" class="block text-neutral-dark">Selecciona una de las opciones.</p>
<!-- /hint -->
<div class="c-radios" data-module="c-radios">
<div class=" c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="legend-as-page-heading" name="legend-as-page-heading" type="radio" value="part-2" aria-describedby="legend-as-page-heading-item-hint">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="legend-as-page-heading">Por correo electrónico</label>
<!-- /label -->
<!-- hint -->
<p id="legend-as-page-heading-item-hint" class="block text-neutral-dark">Asegúrate de que nuestros correos no lleguen a la bandeja de spam.</p>
<!-- /hint -->
</div>
</div>
</div>
</div>
<div class=" c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="legend-as-page-heading-2" name="legend-as-page-heading" type="radio" value="part-3" aria-describedby="legend-as-page-heading-2-item-hint">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="legend-as-page-heading-2">Por correo postal</label>
<!-- /label -->
<!-- hint -->
<p id="legend-as-page-heading-2-item-hint" class="block text-neutral-dark">Asegúrate de haber introducido correctamente tu dirección.</p>
<!-- /hint -->
</div>
</div>
</div>
</div>
</div>
</fieldset>
<!-- /fieldset -->
</div>
<!-- /radios -->
Con un legend del tamaño de un encabezado h2 #
Mostrar códigodel ejemplo: Con un legend del tamaño de un encabezado h2
Contenido
Nunjucks macro
{% from "components/radios/_macro.radios.njk" import componentRadios %}
{{ componentRadios({
"idPrefix": "medium-legend",
"name": "medium-legend",
"fieldset": {
"legend": {
"text": "¿Cómo prefieres que te contactemos?",
"classes": "c-h2"
}
},
"hint": {
"text": "Selecciona una de las opciones."
},
"items": [
{
"value": "part-2",
"text": "Por correo electrónico",
"hint": {
"text": "Asegúrate de que nuestros correos no lleguen a la bandeja de spam."
}
},
{
"value": "part-3",
"text": "Por correo postal",
"hint": {
"text": "Asegúrate de haber introducido correctamente tu dirección."
}
}
]
}) }}
HTML
<!-- radios -->
<div class="c-form-group">
<!-- fieldset -->
<fieldset aria-describedby="medium-legend-hint">
<legend class="c-h2">
¿Cómo prefieres que te contactemos?
</legend>
<!-- hint -->
<p id="medium-legend-hint" class="block text-neutral-dark">Selecciona una de las opciones.</p>
<!-- /hint -->
<div class="c-radios" data-module="c-radios">
<div class=" c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="medium-legend" name="medium-legend" type="radio" value="part-2" aria-describedby="medium-legend-item-hint">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="medium-legend">Por correo electrónico</label>
<!-- /label -->
<!-- hint -->
<p id="medium-legend-item-hint" class="block text-neutral-dark">Asegúrate de que nuestros correos no lleguen a la bandeja de spam.</p>
<!-- /hint -->
</div>
</div>
</div>
</div>
<div class=" c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="medium-legend-2" name="medium-legend" type="radio" value="part-3" aria-describedby="medium-legend-2-item-hint">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="medium-legend-2">Por correo postal</label>
<!-- /label -->
<!-- hint -->
<p id="medium-legend-2-item-hint" class="block text-neutral-dark">Asegúrate de haber introducido correctamente tu dirección.</p>
<!-- /hint -->
</div>
</div>
</div>
</div>
</div>
</fieldset>
<!-- /fieldset -->
</div>
<!-- /radios -->
Con un divisor #
Mostrar códigodel ejemplo: Con un divisor
Contenido
Nunjucks macro
{% from "components/radios/_macro.radios.njk" import componentRadios %}
{{ componentRadios({
"idPrefix": "example-divider",
"name": "example-divider",
"fieldset": {
"legend": {
"text": "¿Cómo prefieres que te contactemos?"
}
},
"items": [
{
"value": "correo-electronico",
"text": "Correo electrónico"
},
{
"value": "correo-postal",
"text": "Correo postal"
},
{
"divider": "o bien"
},
{
"value": "telefono",
"text": "Teléfono"
}
]
}) }}
HTML
<!-- radios -->
<div class="c-form-group">
<!-- fieldset -->
<fieldset>
<legend class="font-bold">
¿Cómo prefieres que te contactemos?
</legend>
<div class="c-radios" data-module="c-radios">
<div class=" c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="example-divider" name="example-divider" type="radio" value="correo-electronico">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="example-divider">Correo electrónico</label>
<!-- /label -->
</div>
</div>
</div>
</div>
<div class=" c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="example-divider-2" name="example-divider" type="radio" value="correo-postal">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="example-divider-2">Correo postal</label>
<!-- /label -->
</div>
</div>
</div>
</div>
<div class=" c-radios__conditional-hidden ">
<div>
<p>o bien</p>
</div>
</div>
<div class=" c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="example-divider-4" name="example-divider" type="radio" value="telefono">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="example-divider-4">Teléfono</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</div>
</fieldset>
<!-- /fieldset -->
</div>
<!-- /radios -->
Con pistas en los items #
Mostrar códigodel ejemplo: Con pistas en los items
Contenido
Nunjucks macro
{% from "components/radios/_macro.radios.njk" import componentRadios %}
{{ componentRadios({
"idPrefix": "hints-on-items",
"name": "hints-on-items",
"fieldset": {
"legend": {
"text": "¿Cómo prefieres que te contactemos?",
"isPageHeading": true
}
},
"items": [
{
"value": "correo-electronico",
"text": "Correo electrónico",
"hint": {
"text": "Asegúrate de que el correo no llega a la bandeja de spam."
}
},
{
"value": "correo-postal",
"text": "Correo postal",
"hint": {
"text": "Asegúrate de haber introducido la dirección postal correctamente."
}
}
]
}) }}
HTML
<!-- radios -->
<div class="c-form-group">
<!-- fieldset -->
<fieldset>
<legend class="font-bold">
<h1>
¿Cómo prefieres que te contactemos?
</h1>
</legend>
<div class="c-radios" data-module="c-radios">
<div class=" c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="hints-on-items" name="hints-on-items" type="radio" value="correo-electronico" aria-describedby="hints-on-items-item-hint">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="hints-on-items">Correo electrónico</label>
<!-- /label -->
<!-- hint -->
<p id="hints-on-items-item-hint" class="block text-neutral-dark">Asegúrate de que el correo no llega a la bandeja de spam.</p>
<!-- /hint -->
</div>
</div>
</div>
</div>
<div class=" c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="hints-on-items-2" name="hints-on-items" type="radio" value="correo-postal" aria-describedby="hints-on-items-2-item-hint">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="hints-on-items-2">Correo postal</label>
<!-- /label -->
<!-- hint -->
<p id="hints-on-items-2-item-hint" class="block text-neutral-dark">Asegúrate de haber introducido la dirección postal correctamente.</p>
<!-- /hint -->
</div>
</div>
</div>
</div>
</div>
</fieldset>
<!-- /fieldset -->
</div>
<!-- /radios -->
Con líneas divisorias #
Mostrar códigodel ejemplo: Con líneas divisorias
Contenido
Nunjucks macro
{% from "components/radios/_macro.radios.njk" import componentRadios %}
{{ componentRadios({
"idPrefix": "has-dividers",
"name": "has-dividers",
"fieldset": {
"legend": {
"text": "¿Cómo prefieres que te contactemos?"
}
},
"hint": {
"text": "Sólo puedes elegir un elemento."
},
"hasDividers": true,
"items": [
{
"value": "correo-electronico",
"text": "Correo electrónico",
"classes": "font-normal",
"hint": {
"text": "Asegúrate de que el correo no llega a la bandeja de spam."
}
},
{
"value": "correo-postal",
"text": "Correo postal",
"hint": {
"text": "Asegúrate de haber introducido la dirección postal correctamente."
}
}
]
}) }}
HTML
<!-- radios -->
<div class="c-form-group">
<!-- fieldset -->
<fieldset aria-describedby="has-dividers-hint">
<legend class="font-bold">
¿Cómo prefieres que te contactemos?
</legend>
<!-- hint -->
<p id="has-dividers-hint" class="block text-neutral-dark">Sólo puedes elegir un elemento.</p>
<!-- /hint -->
<div class="c-radios" data-module="c-radios">
<div class=" border-t border-b border-neutral-base -mb-px font-normal c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="has-dividers" name="has-dividers" type="radio" value="correo-electronico" aria-describedby="has-dividers-item-hint">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="has-dividers">Correo electrónico</label>
<!-- /label -->
<!-- hint -->
<p id="has-dividers-item-hint" class="block text-neutral-dark">Asegúrate de que el correo no llega a la bandeja de spam.</p>
<!-- /hint -->
</div>
</div>
</div>
</div>
<div class=" border-t border-b border-neutral-base -mb-px c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="has-dividers-2" name="has-dividers" type="radio" value="correo-postal" aria-describedby="has-dividers-2-item-hint">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="has-dividers-2">Correo postal</label>
<!-- /label -->
<!-- hint -->
<p id="has-dividers-2-item-hint" class="block text-neutral-dark">Asegúrate de haber introducido la dirección postal correctamente.</p>
<!-- /hint -->
</div>
</div>
</div>
</div>
</div>
</fieldset>
<!-- /fieldset -->
</div>
<!-- /radios -->
Con clases de css aplicadas #
Los parámetros classes
nos permiten aplicar clases de Tailwind CSS a nuestro componente.
Mostrar códigodel ejemplo: Con clases de css aplicadas
Contenido
Nunjucks macro
{% from "components/radios/_macro.radios.njk" import componentRadios %}
{{ componentRadios({
"idPrefix": "classes",
"name": "classes",
"fieldset": {
"legend": {
"text": "¿Cómo prefieres que te contactemos?",
"isPageHeading": true
}
},
"items": [
{
"value": "correo-electronico",
"text": "Correo electrónico",
"hint": {
"text": "Asegúrate de que el correo no llega a la bandeja de spam."
},
"classes": "bg-primary-light"
},
{
"value": "correo-postal",
"text": "Correo postal",
"hint": {
"text": "Asegúrate de haber introducido la dirección postal correctamente."
},
"classes": "bg-neutral-lighter"
}
]
}) }}
HTML
<!-- radios -->
<div class="c-form-group">
<!-- fieldset -->
<fieldset>
<legend class="font-bold">
<h1>
¿Cómo prefieres que te contactemos?
</h1>
</legend>
<div class="c-radios" data-module="c-radios">
<div class=" bg-primary-light c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="classes" name="classes" type="radio" value="correo-electronico" aria-describedby="classes-item-hint">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="classes">Correo electrónico</label>
<!-- /label -->
<!-- hint -->
<p id="classes-item-hint" class="block text-neutral-dark">Asegúrate de que el correo no llega a la bandeja de spam.</p>
<!-- /hint -->
</div>
</div>
</div>
</div>
<div class=" bg-neutral-lighter c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="classes-2" name="classes" type="radio" value="correo-postal" aria-describedby="classes-2-item-hint">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="classes-2">Correo postal</label>
<!-- /label -->
<!-- hint -->
<p id="classes-2-item-hint" class="block text-neutral-dark">Asegúrate de haber introducido la dirección postal correctamente.</p>
<!-- /hint -->
</div>
</div>
</div>
</div>
</div>
</fieldset>
<!-- /fieldset -->
</div>
<!-- /radios -->
Sin fieldset #
Mostrar códigodel ejemplo: Sin fieldset
Contenido
Nunjucks macro
{% from "components/radios/_macro.radios.njk" import componentRadios %}
{{ componentRadios({
"idPrefix": "without-fieldset",
"name": "without-fieldset",
"items": [
{
"value": "correo-electronico",
"text": "Correo electrónico"
},
{
"value": "correp-postal",
"text": "Correo postal"
},
{
"value": "telefono",
"text": "Teléfono"
}
]
}) }}
HTML
<!-- radios -->
<div class="c-form-group">
<div class="c-radios" data-module="c-radios">
<div class=" c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="without-fieldset" name="without-fieldset" type="radio" value="correo-electronico">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="without-fieldset">Correo electrónico</label>
<!-- /label -->
</div>
</div>
</div>
</div>
<div class=" c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="without-fieldset-2" name="without-fieldset" type="radio" value="correp-postal">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="without-fieldset-2">Correo postal</label>
<!-- /label -->
</div>
</div>
</div>
</div>
<div class=" c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="without-fieldset-3" name="without-fieldset" type="radio" value="telefono">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="without-fieldset-3">Teléfono</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /radios -->
Con fieldset y mensaje de error #
Mostrar códigodel ejemplo: Con fieldset y mensaje de error
Contenido
Nunjucks macro
{% from "components/radios/_macro.radios.njk" import componentRadios %}
{{ componentRadios({
"idPrefix": "fieldset-and-error",
"name": "fieldset-and-error",
"errorMessage": {
"text": "Error: Tienes que seleccionar al menos una opción"
},
"fieldset": {
"legend": {
"text": "¿Quieres que te contactemos por correo electrónico?"
}
},
"items": [
{
"value": "si",
"text": "Si"
},
{
"value": "no",
"text": "No",
"checked": true
}
]
}) }}
HTML
<!-- radios -->
<div class="c-form-group c-form-group--error">
<!-- fieldset -->
<fieldset aria-describedby="fieldset-and-error-error" aria-errormessage="fieldset-and-error-error">
<legend class="font-bold">
¿Quieres que te contactemos por correo electrónico?
</legend>
<!-- error-message -->
<p id="fieldset-and-error-error" class="block font-semibold text-alert-base">
<span class="sr-only">Error:</span>Error: Tienes que seleccionar al menos una opción
</p>
<!-- /error-message -->
<div class="c-radios" data-module="c-radios">
<div class=" c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="fieldset-and-error" name="fieldset-and-error" type="radio" value="si" aria-invalid="true">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="fieldset-and-error">Si</label>
<!-- /label -->
</div>
</div>
</div>
</div>
<div class=" c-radios__conditional-active ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="fieldset-and-error-2" name="fieldset-and-error" type="radio" value="no" checked aria-invalid="true">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="fieldset-and-error-2">No</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</div>
</fieldset>
<!-- /fieldset -->
</div>
<!-- /radios -->
Con un texto de item muy largo #
Mostrar códigodel ejemplo: Con un texto de item muy largo
Contenido
Nunjucks macro
{% from "components/radios/_macro.radios.njk" import componentRadios %}
{{ componentRadios({
"idPrefix": "very-long",
"name": "very-long",
"hint": {
"text": "Nullam id dolor id nibh ultricies vehicula ut id elit."
},
"errorMessage": {
"text": "Error: Lorem ipsum dolor sit amet, consectetur adipiscing elit."
},
"fieldset": {
"legend": {
"text": "Maecenas faucibus mollis interdum?"
}
},
"items": [
{
"value": "nullam",
"text": "Nullam id dolor id nibh ultricies vehicula ut id elit. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Maecenas faucibus mollis interdum. Donec id elit non mi porta gravida at eget metus."
},
{
"value": "aenean",
"text": "Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Donec sed odio dui. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Cras mattis consectetur purus sit amet fermentum."
},
{
"value": "fusce",
"text": "Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Etiam porta sem malesuada magna mollis euismod. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. Sed posuere consectetur est at lobortis."
}
]
}) }}
HTML
<!-- radios -->
<div class="c-form-group c-form-group--error">
<!-- fieldset -->
<fieldset aria-describedby="very-long-hint very-long-error" aria-errormessage="very-long-error">
<legend class="font-bold">
Maecenas faucibus mollis interdum?
</legend>
<!-- hint -->
<p id="very-long-hint" class="block text-neutral-dark">Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
<!-- /hint -->
<!-- error-message -->
<p id="very-long-error" class="block font-semibold text-alert-base">
<span class="sr-only">Error:</span>Error: Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</p>
<!-- /error-message -->
<div class="c-radios" data-module="c-radios">
<div class=" c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="very-long" name="very-long" type="radio" value="nullam" aria-invalid="true">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="very-long">Nullam id dolor id nibh ultricies vehicula ut id elit. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Maecenas faucibus mollis interdum. Donec id elit non mi porta gravida at eget metus.</label>
<!-- /label -->
</div>
</div>
</div>
</div>
<div class=" c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="very-long-2" name="very-long" type="radio" value="aenean" aria-invalid="true">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="very-long-2">Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Donec sed odio dui. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Cras mattis consectetur purus sit amet fermentum.</label>
<!-- /label -->
</div>
</div>
</div>
</div>
<div class=" c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="very-long-3" name="very-long" type="radio" value="fusce" aria-invalid="true">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="very-long-3">Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Etiam porta sem malesuada magna mollis euismod. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. Sed posuere consectetur est at lobortis.</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</div>
</fieldset>
<!-- /fieldset -->
</div>
<!-- /radios -->
Con items condicionales #
Mostrar códigodel ejemplo: Con items condicionales
Contenido
Nunjucks macro
{% from "components/radios/_macro.radios.njk" import componentRadios %}
{{ componentRadios({
"idPrefix": "conditional-items",
"name": "conditional-items",
"fieldset": {
"legend": {
"text": "¿Cómo quieres que te contactemos?"
}
},
"items": [
{
"value": "correo-electronico",
"text": "Correo electrónico",
"conditional": {
"html": " <!-- input -->\n<div class=\"c-form-group\">\n <!-- label -->\n <label class=\"block\" for=\"mobile-1\">Número de teléfono móvil</label>\n <!-- /label -->\n <input class=\"c-input block mt-sm border-black rounded font-semibold placeholder-neutral-dark focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base\" id=\"mobile-1\" name=\"mobile-name-1\" type=\"text\">\n</div>\n<!-- /input -->\n"
}
},
{
"value": "telefono",
"text": "Teléfono",
"checked": true,
"conditional": {
"html": " <!-- input -->\n<div class=\"c-form-group\">\n <!-- label -->\n <label class=\"block\" for=\"telefono-2\">Número de teléfono</label>\n <!-- /label -->\n <input class=\"c-input block mt-sm border-black rounded font-semibold placeholder-neutral-dark focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base\" id=\"telefono-2\" name=\"telefono-name-2\" type=\"text\">\n</div>\n<!-- /input -->\n"
}
},
{
"value": "mensaje-SMS",
"text": "Sin conditional"
}
]
}) }}
HTML
<!-- radios -->
<div class="c-form-group">
<!-- fieldset -->
<fieldset>
<legend class="font-bold">
¿Cómo quieres que te contactemos?
</legend>
<div class="c-radios" data-module="c-radios">
<div class=" c-radios__conditional c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="conditional-items" name="conditional-items" type="radio" value="correo-electronico" data-aria-controls="conditional-conditional-items">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="conditional-items">Correo electrónico</label>
<!-- /label -->
</div>
</div>
</div>
<div class="mb-lg ml-5 pt-sm pb-base pl-6 origin-top-left border-l-2 border-primary-base c-radios__conditional-item" id="conditional-conditional-items">
<!-- input -->
<div class="c-form-group">
<!-- label -->
<label class="block" for="mobile-1">Número de teléfono móvil</label>
<!-- /label -->
<input class="c-input block mt-sm border-black rounded font-semibold placeholder-neutral-dark focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base" id="mobile-1" name="mobile-name-1" type="text">
</div>
<!-- /input -->
</div>
</div>
<div class=" c-radios__conditional c-radios__conditional-active ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="conditional-items-2" name="conditional-items" type="radio" value="telefono" checked data-aria-controls="conditional-conditional-items-2">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="conditional-items-2">Teléfono</label>
<!-- /label -->
</div>
</div>
</div>
<div class="mb-lg ml-5 pt-sm pb-base pl-6 origin-top-left border-l-2 border-primary-base c-radios__conditional-item" id="conditional-conditional-items-2">
<!-- input -->
<div class="c-form-group">
<!-- label -->
<label class="block" for="telefono-2">Número de teléfono</label>
<!-- /label -->
<input class="c-input block mt-sm border-black rounded font-semibold placeholder-neutral-dark focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base" id="telefono-2" name="telefono-name-2" type="text">
</div>
<!-- /input -->
</div>
</div>
<div class=" c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="conditional-items-3" name="conditional-items" type="radio" value="mensaje-SMS">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="conditional-items-3">Sin conditional</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</div>
</fieldset>
<!-- /fieldset -->
</div>
<!-- /radios -->
Con items condicionales anidados #
Mostrar códigodel ejemplo: Con items condicionales anidados
Contenido
Nunjucks macro
{% from "components/radios/_macro.radios.njk" import componentRadios %}
{{ componentRadios({
"idPrefix": "with-conditional-nested-items",
"name": "with-conditional-nested-items",
"fieldset": {
"legend": {
"text": "¿Cómo quieres que te contactemos?"
}
},
"items": [
{
"value": "presencial",
"text": "Presencial",
"checked": true,
"conditional": {
"html": " \n\n<!-- radios -->\n<div class=\"c-form-group\">\n <div class=\"c-radios\" data-module=\"c-radios\">\n <div class=\" c-radios__conditional c-radios__conditional-active \">\n <div>\n <div class=\"relative flex items-start py-base\">\n <div class=\"flex items-center mx-sm\">\n <input class=\"w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base\" id=\"with-conditional-items-checked-nested-1\" name=\"with-conditional-items-checked-nested-1\" type=\"radio\" value=\"oficinas-de-registro\" checked data-aria-controls=\"conditional-with-conditional-items-checked-nested-1\">\n </div>\n <div class=\"pt-0.5 leading-5\">\n <!-- label -->\n <label class=\"block\" for=\"with-conditional-items-checked-nested-1\">Oficinas de registro</label>\n <!-- /label -->\n </div>\n </div>\n </div>\n <div class=\"mb-lg ml-5 pt-sm pb-base pl-6 origin-top-left border-l-2 border-primary-base c-radios__conditional-item\" id=\"conditional-with-conditional-items-checked-nested-1\">\n \n \n <!-- radios -->\n <div class=\"c-form-group\">\n <div class=\"c-radios\" data-module=\"c-radios\">\n <div class=\" c-radios__conditional-active \">\n <div>\n <div class=\"relative flex items-start py-base\">\n <div class=\"flex items-center mx-sm\">\n <input class=\"w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base\" id=\"oficina-principal-id-oficinas-de-registro-1\" name=\"grandchild-oficinas-de-registro-1\" type=\"radio\" value=\"oficina-principal-oficinas-de-registro-1\" checked>\n </div>\n <div class=\"pt-0.5 leading-5\">\n <!-- label -->\n <label class=\"block\" for=\"oficina-principal-id-oficinas-de-registro-1\">Oficina principal</label>\n <!-- /label -->\n </div>\n </div>\n </div>\n </div>\n <div class=\" c-radios__conditional-hidden \">\n <div>\n <div class=\"relative flex items-start py-base\">\n <div class=\"flex items-center mx-sm\">\n <input class=\"w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base\" id=\"oficina-secundaria-id-oficinas-de-registro-1\" name=\"grandchild-oficinas-de-registro-1\" type=\"radio\" value=\"oficina-secundaria-oficinas-de-registro-1\">\n </div>\n <div class=\"pt-0.5 leading-5\">\n <!-- label -->\n <label class=\"block\" for=\"oficina-secundaria-id-oficinas-de-registro-1\">Oficina secundaria</label>\n <!-- /label -->\n </div>\n </div>\n </div>\n </div>\n </div>\n \n </div>\n <!-- /radios -->\n \n \n </div>\n </div>\n <div class=\" c-radios__conditional c-radios__conditional-hidden \">\n <div>\n <div class=\"relative flex items-start py-base\">\n <div class=\"flex items-center mx-sm\">\n <input class=\"w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base\" id=\"with-conditional-items-checked-nested-1-2\" name=\"with-conditional-items-checked-nested-1\" type=\"radio\" value=\"oficinas-locales\" data-aria-controls=\"conditional-with-conditional-items-checked-nested-1-2\">\n </div>\n <div class=\"pt-0.5 leading-5\">\n <!-- label -->\n <label class=\"block\" for=\"with-conditional-items-checked-nested-1-2\">Oficinas locales</label>\n <!-- /label -->\n </div>\n </div>\n </div>\n <div class=\"mb-lg ml-5 pt-sm pb-base pl-6 origin-top-left border-l-2 border-primary-base c-radios__conditional-item\" id=\"conditional-with-conditional-items-checked-nested-1-2\">\n \n \n <!-- radios -->\n <div class=\"c-form-group\">\n <div class=\"c-radios\" data-module=\"c-radios\">\n <div class=\" c-radios__conditional-active \">\n <div>\n <div class=\"relative flex items-start py-base\">\n <div class=\"flex items-center mx-sm\">\n <input class=\"w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base\" id=\"oficina-principal-id-oficinas-locales-1\" name=\"grandchild-oficinas-locales-1\" type=\"radio\" value=\"oficina-principal-oficinas-locales-1\" checked>\n </div>\n <div class=\"pt-0.5 leading-5\">\n <!-- label -->\n <label class=\"block\" for=\"oficina-principal-id-oficinas-locales-1\">Oficina principal</label>\n <!-- /label -->\n </div>\n </div>\n </div>\n </div>\n <div class=\" c-radios__conditional-hidden \">\n <div>\n <div class=\"relative flex items-start py-base\">\n <div class=\"flex items-center mx-sm\">\n <input class=\"w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base\" id=\"oficina-secundaria-id-oficinas-locales-1\" name=\"grandchild-oficinas-locales-1\" type=\"radio\" value=\"oficina-secundaria-oficinas-locales-1\">\n </div>\n <div class=\"pt-0.5 leading-5\">\n <!-- label -->\n <label class=\"block\" for=\"oficina-secundaria-id-oficinas-locales-1\">Oficina secundaria</label>\n <!-- /label -->\n </div>\n </div>\n </div>\n </div>\n </div>\n \n </div>\n <!-- /radios -->\n \n \n </div>\n </div>\n </div>\n \n</div>\n<!-- /radios -->\n\n"
}
},
{
"value": "telefono",
"text": "Por teléfono"
}
]
}) }}
HTML
<!-- radios -->
<div class="c-form-group">
<!-- fieldset -->
<fieldset>
<legend class="font-bold">
¿Cómo quieres que te contactemos?
</legend>
<div class="c-radios" data-module="c-radios">
<div class=" c-radios__conditional c-radios__conditional-active ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="with-conditional-nested-items" name="with-conditional-nested-items" type="radio" value="presencial" checked data-aria-controls="conditional-with-conditional-nested-items">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="with-conditional-nested-items">Presencial</label>
<!-- /label -->
</div>
</div>
</div>
<div class="mb-lg ml-5 pt-sm pb-base pl-6 origin-top-left border-l-2 border-primary-base c-radios__conditional-item" id="conditional-with-conditional-nested-items">
<!-- radios -->
<div class="c-form-group">
<div class="c-radios" data-module="c-radios">
<div class=" c-radios__conditional c-radios__conditional-active ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="with-conditional-items-checked-nested-1" name="with-conditional-items-checked-nested-1" type="radio" value="oficinas-de-registro" checked data-aria-controls="conditional-with-conditional-items-checked-nested-1">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="with-conditional-items-checked-nested-1">Oficinas de registro</label>
<!-- /label -->
</div>
</div>
</div>
<div class="mb-lg ml-5 pt-sm pb-base pl-6 origin-top-left border-l-2 border-primary-base c-radios__conditional-item" id="conditional-with-conditional-items-checked-nested-1">
<!-- radios -->
<div class="c-form-group">
<div class="c-radios" data-module="c-radios">
<div class=" c-radios__conditional-active ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="oficina-principal-id-oficinas-de-registro-1" name="grandchild-oficinas-de-registro-1" type="radio" value="oficina-principal-oficinas-de-registro-1" checked>
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="oficina-principal-id-oficinas-de-registro-1">Oficina principal</label>
<!-- /label -->
</div>
</div>
</div>
</div>
<div class=" c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="oficina-secundaria-id-oficinas-de-registro-1" name="grandchild-oficinas-de-registro-1" type="radio" value="oficina-secundaria-oficinas-de-registro-1">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="oficina-secundaria-id-oficinas-de-registro-1">Oficina secundaria</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /radios -->
</div>
</div>
<div class=" c-radios__conditional c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="with-conditional-items-checked-nested-1-2" name="with-conditional-items-checked-nested-1" type="radio" value="oficinas-locales" data-aria-controls="conditional-with-conditional-items-checked-nested-1-2">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="with-conditional-items-checked-nested-1-2">Oficinas locales</label>
<!-- /label -->
</div>
</div>
</div>
<div class="mb-lg ml-5 pt-sm pb-base pl-6 origin-top-left border-l-2 border-primary-base c-radios__conditional-item" id="conditional-with-conditional-items-checked-nested-1-2">
<!-- radios -->
<div class="c-form-group">
<div class="c-radios" data-module="c-radios">
<div class=" c-radios__conditional-active ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="oficina-principal-id-oficinas-locales-1" name="grandchild-oficinas-locales-1" type="radio" value="oficina-principal-oficinas-locales-1" checked>
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="oficina-principal-id-oficinas-locales-1">Oficina principal</label>
<!-- /label -->
</div>
</div>
</div>
</div>
<div class=" c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="oficina-secundaria-id-oficinas-locales-1" name="grandchild-oficinas-locales-1" type="radio" value="oficina-secundaria-oficinas-locales-1">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="oficina-secundaria-id-oficinas-locales-1">Oficina secundaria</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /radios -->
</div>
</div>
</div>
</div>
<!-- /radios -->
</div>
</div>
<div class=" c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="with-conditional-nested-items-2" name="with-conditional-nested-items" type="radio" value="telefono">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="with-conditional-nested-items-2">Por teléfono</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</div>
</fieldset>
<!-- /fieldset -->
</div>
<!-- /radios -->
En línea con items condicionales #
Mostrar códigodel ejemplo: En línea con items condicionales
Contenido
Nunjucks macro
{% from "components/radios/_macro.radios.njk" import componentRadios %}
{{ componentRadios({
"classes": "flex",
"idPrefix": "inline-with-conditional",
"name": "inline-with-conditional",
"fieldset": {
"legend": {
"text": "¿Cómo quieres que te contactemos?"
}
},
"items": [
{
"value": "correo-electronico",
"text": "Correo electrónico",
"classes": "mr-sm",
"conditional": {
"html": " <!-- input -->\n<div class=\"c-form-group\">\n <!-- label -->\n <label class=\"block\" for=\"telefono-3\">Número de teléfono</label>\n <!-- /label -->\n <input class=\"c-input block mt-sm border-black rounded font-semibold placeholder-neutral-dark focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base\" id=\"telefono-3\" name=\"telefono-name-3\" type=\"text\">\n</div>\n<!-- /input -->\n"
}
},
{
"value": "telefono",
"text": "Teléfono",
"classes": "mr-sm",
"checked": true,
"conditional": {
"html": " <!-- input -->\n<div class=\"c-form-group\">\n <!-- label -->\n <label class=\"block\" for=\"mobile-3\">Número de teléfono móvil</label>\n <!-- /label -->\n <input class=\"c-input block mt-sm border-black rounded font-semibold placeholder-neutral-dark focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base\" id=\"mobile-3\" name=\"mobile-name-3\" type=\"text\">\n</div>\n<!-- /input -->\n"
}
},
{
"value": "mensaje-SMS",
"text": "Mensaje SMS",
"classes": "mr-sm",
"conditional": {
"html": " <!-- input -->\n<div class=\"c-form-group\">\n <!-- label -->\n <label class=\"block\" for=\"mobile-4\">Número de teléfono móvil</label>\n <!-- /label -->\n <input class=\"c-input block mt-sm border-black rounded font-semibold placeholder-neutral-dark focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base\" id=\"mobile-4\" name=\"mobile-name-4\" type=\"text\">\n</div>\n<!-- /input -->\n"
}
}
]
}) }}
HTML
<!-- radios -->
<div class="c-form-group">
<!-- fieldset -->
<fieldset>
<legend class="font-bold">
¿Cómo quieres que te contactemos?
</legend>
<div class="c-radios flex" data-module="c-radios">
<div class=" mr-sm c-radios__conditional c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="inline-with-conditional" name="inline-with-conditional" type="radio" value="correo-electronico" data-aria-controls="conditional-inline-with-conditional">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="inline-with-conditional">Correo electrónico</label>
<!-- /label -->
</div>
</div>
</div>
<div class="mb-lg ml-5 pt-sm pb-base pl-6 origin-top-left border-l-2 border-primary-base c-radios__conditional-item" id="conditional-inline-with-conditional">
<!-- input -->
<div class="c-form-group">
<!-- label -->
<label class="block" for="telefono-3">Número de teléfono</label>
<!-- /label -->
<input class="c-input block mt-sm border-black rounded font-semibold placeholder-neutral-dark focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base" id="telefono-3" name="telefono-name-3" type="text">
</div>
<!-- /input -->
</div>
</div>
<div class=" mr-sm c-radios__conditional c-radios__conditional-active ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="inline-with-conditional-2" name="inline-with-conditional" type="radio" value="telefono" checked data-aria-controls="conditional-inline-with-conditional-2">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="inline-with-conditional-2">Teléfono</label>
<!-- /label -->
</div>
</div>
</div>
<div class="mb-lg ml-5 pt-sm pb-base pl-6 origin-top-left border-l-2 border-primary-base c-radios__conditional-item" id="conditional-inline-with-conditional-2">
<!-- input -->
<div class="c-form-group">
<!-- label -->
<label class="block" for="mobile-3">Número de teléfono móvil</label>
<!-- /label -->
<input class="c-input block mt-sm border-black rounded font-semibold placeholder-neutral-dark focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base" id="mobile-3" name="mobile-name-3" type="text">
</div>
<!-- /input -->
</div>
</div>
<div class=" mr-sm c-radios__conditional c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="inline-with-conditional-3" name="inline-with-conditional" type="radio" value="mensaje-SMS" data-aria-controls="conditional-inline-with-conditional-3">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="inline-with-conditional-3">Mensaje SMS</label>
<!-- /label -->
</div>
</div>
</div>
<div class="mb-lg ml-5 pt-sm pb-base pl-6 origin-top-left border-l-2 border-primary-base c-radios__conditional-item" id="conditional-inline-with-conditional-3">
<!-- input -->
<div class="c-form-group">
<!-- label -->
<label class="block" for="mobile-4">Número de teléfono móvil</label>
<!-- /label -->
<input class="c-input block mt-sm border-black rounded font-semibold placeholder-neutral-dark focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base" id="mobile-4" name="mobile-name-4" type="text">
</div>
<!-- /input -->
</div>
</div>
</div>
</fieldset>
<!-- /fieldset -->
</div>
<!-- /radios -->
Con item condicional seleccionado #
Mostrar códigodel ejemplo: Con item condicional seleccionado
Contenido
Nunjucks macro
{% from "components/radios/_macro.radios.njk" import componentRadios %}
{{ componentRadios({
"idPrefix": "conditional-item-checked",
"name": "conditional-item-checked",
"fieldset": {
"legend": {
"text": "¿Cómo quieres que te contactemos?"
}
},
"items": [
{
"value": "correo-electronico",
"text": "Correo electrónico",
"conditional": {
"html": " <!-- input -->\n<div class=\"c-form-group\">\n <!-- label -->\n <label class=\"block\" for=\"telefono-4\">Número de teléfono</label>\n <!-- /label -->\n <input class=\"c-input block mt-sm border-black rounded font-semibold placeholder-neutral-dark focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base\" id=\"telefono-4\" name=\"telefono-name-4\" type=\"text\">\n</div>\n<!-- /input -->\n"
}
},
{
"value": "telefono",
"text": "Teléfono",
"checked": true,
"conditional": {
"html": " <!-- input -->\n<div class=\"c-form-group\">\n <!-- label -->\n <label class=\"block\" for=\"mobile-5\">Número de teléfono móvil</label>\n <!-- /label -->\n <input class=\"c-input block mt-sm border-black rounded font-semibold placeholder-neutral-dark focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base\" id=\"mobile-5\" name=\"mobile-name-5\" type=\"text\">\n</div>\n<!-- /input -->\n"
}
},
{
"value": "mensaje-SMS",
"text": "Mensaje SMS",
"conditional": {
"html": " <!-- input -->\n<div class=\"c-form-group\">\n <!-- label -->\n <label class=\"block\" for=\"mobile-6\">Número de teléfono móvil</label>\n <!-- /label -->\n <input class=\"c-input block mt-sm border-black rounded font-semibold placeholder-neutral-dark focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base\" id=\"mobile-6\" name=\"mobile-name-6\" type=\"text\">\n</div>\n<!-- /input -->\n"
}
}
]
}) }}
HTML
<!-- radios -->
<div class="c-form-group">
<!-- fieldset -->
<fieldset>
<legend class="font-bold">
¿Cómo quieres que te contactemos?
</legend>
<div class="c-radios" data-module="c-radios">
<div class=" c-radios__conditional c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="conditional-item-checked" name="conditional-item-checked" type="radio" value="correo-electronico" data-aria-controls="conditional-conditional-item-checked">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="conditional-item-checked">Correo electrónico</label>
<!-- /label -->
</div>
</div>
</div>
<div class="mb-lg ml-5 pt-sm pb-base pl-6 origin-top-left border-l-2 border-primary-base c-radios__conditional-item" id="conditional-conditional-item-checked">
<!-- input -->
<div class="c-form-group">
<!-- label -->
<label class="block" for="telefono-4">Número de teléfono</label>
<!-- /label -->
<input class="c-input block mt-sm border-black rounded font-semibold placeholder-neutral-dark focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base" id="telefono-4" name="telefono-name-4" type="text">
</div>
<!-- /input -->
</div>
</div>
<div class=" c-radios__conditional c-radios__conditional-active ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="conditional-item-checked-2" name="conditional-item-checked" type="radio" value="telefono" checked data-aria-controls="conditional-conditional-item-checked-2">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="conditional-item-checked-2">Teléfono</label>
<!-- /label -->
</div>
</div>
</div>
<div class="mb-lg ml-5 pt-sm pb-base pl-6 origin-top-left border-l-2 border-primary-base c-radios__conditional-item" id="conditional-conditional-item-checked-2">
<!-- input -->
<div class="c-form-group">
<!-- label -->
<label class="block" for="mobile-5">Número de teléfono móvil</label>
<!-- /label -->
<input class="c-input block mt-sm border-black rounded font-semibold placeholder-neutral-dark focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base" id="mobile-5" name="mobile-name-5" type="text">
</div>
<!-- /input -->
</div>
</div>
<div class=" c-radios__conditional c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="conditional-item-checked-3" name="conditional-item-checked" type="radio" value="mensaje-SMS" data-aria-controls="conditional-conditional-item-checked-3">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="conditional-item-checked-3">Mensaje SMS</label>
<!-- /label -->
</div>
</div>
</div>
<div class="mb-lg ml-5 pt-sm pb-base pl-6 origin-top-left border-l-2 border-primary-base c-radios__conditional-item" id="conditional-conditional-item-checked-3">
<!-- input -->
<div class="c-form-group">
<!-- label -->
<label class="block" for="mobile-6">Número de teléfono móvil</label>
<!-- /label -->
<input class="c-input block mt-sm border-black rounded font-semibold placeholder-neutral-dark focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base" id="mobile-6" name="mobile-name-6" type="text">
</div>
<!-- /input -->
</div>
</div>
</div>
</fieldset>
<!-- /fieldset -->
</div>
<!-- /radios -->
Con clases opcionales del form-group mostrando un error del grupo #
Mostrar códigodel ejemplo: Con clases opcionales del form-group mostrando un error del grupo
Contenido
Nunjucks macro
{% from "components/radios/_macro.radios.njk" import componentRadios %}
{{ componentRadios({
"idPrefix": "classes-group-error",
"name": "classes-group-error",
"formGroup": {
"classes": "c-form-group--error"
},
"fieldset": {
"legend": {
"text": "¿Cómo quieres que te contactemos?"
}
},
"items": [
{
"value": "correo-electronico",
"text": "Correo electrónico",
"conditional": {
"html": " <!-- input -->\n<div class=\"c-form-group\">\n <!-- label -->\n <label class=\"block\" for=\"telefono-5\">Número de teléfono</label>\n <!-- /label -->\n <input class=\"c-input block mt-sm border-black rounded font-semibold placeholder-neutral-dark focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base\" id=\"telefono-5\" name=\"telefono-name-5\" type=\"text\">\n</div>\n<!-- /input -->\n"
}
},
{
"value": "telefono",
"text": "Teléfono",
"checked": true,
"conditional": {
"html": " <!-- input -->\n<div class=\"c-form-group c-form-group--error\">\n <!-- label -->\n <label class=\"block\" for=\"input-with-error-message-1\">Número de teléfono móvil</label>\n <!-- /label -->\n <!-- error-message -->\n <p id=\"input-with-error-message-1-error\" class=\"block font-semibold text-alert-base\">\n <span class=\"sr-only\">Error:</span>Error: Este campo no puede estar vacío\n </p>\n <!-- /error-message -->\n <input class=\"c-input block mt-sm border-black rounded font-semibold placeholder-neutral-dark focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base border-alert-base ring-2 ring-alert-base \" id=\"input-with-error-message-1\" name=\"test-name-1\" type=\"text\" aria-describedby=\"input-with-error-message-1-error\" aria-errormessage=\"input-with-error-message-1-error\" aria-invalid=\"true\">\n</div>\n<!-- /input -->\n"
}
},
{
"value": "mensaje-SMS",
"text": "Mensaje SMS",
"conditional": {
"html": " <!-- input -->\n<div class=\"c-form-group\">\n <!-- label -->\n <label class=\"block\" for=\"mobile-7\">Número de teléfono móvil</label>\n <!-- /label -->\n <input class=\"c-input block mt-sm border-black rounded font-semibold placeholder-neutral-dark focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base\" id=\"mobile-7\" name=\"mobile-name-7\" type=\"text\">\n</div>\n<!-- /input -->\n"
}
}
]
}) }}
HTML
<!-- radios -->
<div class="c-form-group c-form-group--error">
<!-- fieldset -->
<fieldset>
<legend class="font-bold">
¿Cómo quieres que te contactemos?
</legend>
<div class="c-radios" data-module="c-radios">
<div class=" c-radios__conditional c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="classes-group-error" name="classes-group-error" type="radio" value="correo-electronico" data-aria-controls="conditional-classes-group-error">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="classes-group-error">Correo electrónico</label>
<!-- /label -->
</div>
</div>
</div>
<div class="mb-lg ml-5 pt-sm pb-base pl-6 origin-top-left border-l-2 border-primary-base c-radios__conditional-item" id="conditional-classes-group-error">
<!-- input -->
<div class="c-form-group">
<!-- label -->
<label class="block" for="telefono-5">Número de teléfono</label>
<!-- /label -->
<input class="c-input block mt-sm border-black rounded font-semibold placeholder-neutral-dark focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base" id="telefono-5" name="telefono-name-5" type="text">
</div>
<!-- /input -->
</div>
</div>
<div class=" c-radios__conditional c-radios__conditional-active ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="classes-group-error-2" name="classes-group-error" type="radio" value="telefono" checked data-aria-controls="conditional-classes-group-error-2">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="classes-group-error-2">Teléfono</label>
<!-- /label -->
</div>
</div>
</div>
<div class="mb-lg ml-5 pt-sm pb-base pl-6 origin-top-left border-l-2 border-primary-base c-radios__conditional-item" id="conditional-classes-group-error-2">
<!-- input -->
<div class="c-form-group c-form-group--error">
<!-- label -->
<label class="block" for="input-with-error-message-1">Número de teléfono móvil</label>
<!-- /label -->
<!-- error-message -->
<p id="input-with-error-message-1-error" class="block font-semibold text-alert-base">
<span class="sr-only">Error:</span>Error: Este campo no puede estar vacío
</p>
<!-- /error-message -->
<input class="c-input block mt-sm border-black rounded font-semibold placeholder-neutral-dark focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base border-alert-base ring-2 ring-alert-base " id="input-with-error-message-1" name="test-name-1" type="text" aria-describedby="input-with-error-message-1-error" aria-errormessage="input-with-error-message-1-error" aria-invalid="true">
</div>
<!-- /input -->
</div>
</div>
<div class=" c-radios__conditional c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="classes-group-error-3" name="classes-group-error" type="radio" value="mensaje-SMS" data-aria-controls="conditional-classes-group-error-3">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block" for="classes-group-error-3">Mensaje SMS</label>
<!-- /label -->
</div>
</div>
</div>
<div class="mb-lg ml-5 pt-sm pb-base pl-6 origin-top-left border-l-2 border-primary-base c-radios__conditional-item" id="conditional-classes-group-error-3">
<!-- input -->
<div class="c-form-group">
<!-- label -->
<label class="block" for="mobile-7">Número de teléfono móvil</label>
<!-- /label -->
<input class="c-input block mt-sm border-black rounded font-semibold placeholder-neutral-dark focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base" id="mobile-7" name="mobile-name-7" type="text">
</div>
<!-- /input -->
</div>
</div>
</div>
</fieldset>
<!-- /fieldset -->
</div>
<!-- /radios -->
Peque #
Mostrar códigodel ejemplo: Peque
Contenido
Nunjucks macro
{% from "components/radios/_macro.radios.njk" import componentRadios %}
{{ componentRadios({
"idPrefix": "small",
"name": "peque",
"classes": "c-radios--sm",
"items": [
{
"value": "si",
"text": "Si",
"classes": "-mt-base",
"label": {
"classes": "text-sm -mt-1"
}
},
{
"value": "no",
"text": "No",
"classes": "-mt-base",
"label": {
"classes": "text-sm -mt-1"
}
}
]
}) }}
HTML
<!-- radios -->
<div class="c-form-group">
<div class="c-radios c-radios--sm" data-module="c-radios">
<div class=" -mt-base c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="small" name="peque" type="radio" value="si">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block text-sm -mt-1" for="small">Si</label>
<!-- /label -->
</div>
</div>
</div>
</div>
<div class=" -mt-base c-radios__conditional-hidden ">
<div>
<div class="relative flex items-start py-base">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 text-primary-base transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="small-2" name="peque" type="radio" value="no">
</div>
<div class="pt-0.5 leading-5">
<!-- label -->
<label class="block text-sm -mt-1" for="small-2">No</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /radios -->