Tree
Mostrar parámetros
Parámetros del componente
params:
- name: type
type: string
required: false
description: Type of input control to render. Admitted values are `navigation`, `checkbox` and `radio` or not set. Defaults to `radio`.
- name: searchbar
type: component
required: false
description: A searchbar component to filter the items. Inherits all the searchbar component params.
- name: ariaLabel
type: text
required: false
description: aria-label for nav tag. Should be a description of tree type navigation.
- name: hasUnderline
type: boolean
required: false
description: If `true`, all items will be underlined except the disabled ones or the ones that have no href.
- name: describedBy
type: string
required: false
description: One or more element IDs to add to the input `aria-describedby` attribute without a fieldset, used to provide additional descriptive information for screenreader users.
- 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 item if no id is specified on each item.
- name: name
type: string
required: true
description: Name attribute for all checkbox/radio items.
- name: heading
type: object
required: true
description: Options for the heading
params:
- name: text
type: string
required: true
description: If `html` is set, this is not required. Text to use within the heading. 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 the heading. If `html` is provided, the `text` argument will be ignored.
- name: classes
type: string
required: false
description: Classes to add to the heading.
- name: id
type: string
required: false
description: Specific id attribute for the component. If omitted, then idPrefix option will be applied.
- name: headingLevel
type: number
required: false
description: If headingLevel is 1, the parent heading tag needed inside this component will be a h1, if 2 will be a h2, and so on.
- name: items
type: array
required: true
description: Array of tree items objects.
params:
- name: text
type: string
required: true
description: If `html` is set, this is not required. Text to use within each tree 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 tree item label. If `html` is provided, the `text` argument will be ignored.
- name: href
type: string
required: false
description: Item link in tree type navigation.
- name: id
type: string
required: false
description: Specific id attribute for the item. If omitted, then idPrefix option will be applied.
- name: name
type: string
required: true
description: Specific name for the checkbox/radio item. If omitted, then component global `name` string will be applied.
- name: value
type: string
required: true
description: Value for the checkbox/radio input.
- name: label
type: object
required: false
description: Provide attributes and classes to each checkbox/radio item label.
isComponent: true
- name: hint
type: object
required: false
description: Provide hint to each checkbox/radio item.
isComponent: true
- name: checked
type: boolean
required: false
description: If true, checkbox/radio will be checked.
- name: isIndeterminate
type: boolean
required: false
description: If true, the checkbox will have an additional indeterminate state to show a partial true. Only for checkbox item.
- name: indeterminateChecked
type: boolean
required: false
description: If true, the checkbox will have an indeterminate checked initial state. This will override isChecked value. Only for checkbox item.
- name: disabled
type: boolean
required: false
description: If true, tree 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 item.
- name: expanded
type: boolean
required: false
description: If true, tree sub will be expanded.
- name: sub
type: boolean
required: false
description: If true, content provided will be revealed when the item is expanded.
- name: sub.classes
type: string
required: false
description: Classes to add to the sub container.
- name: sub.attributes
type: string
required: false
description: HTML attributes (for example data attributes) to add to the sub container.
- name: sub.items
type: array
required: false
description: Provide subitems for the sub reveal. Each items have same params as this item.
- name: classes
type: string
required: false
description: Classes to add to the tree container.
- name: attributes
type: object
required: false
description: HTML attributes (for example data attributes) to add to the tree container.
Por defecto #
Mostrar códigodel ejemplo: Por defecto
Contenido
Nunjucks macro
{% from "components/tree/_macro.tree.njk" import componentTree %}
{{ componentTree({
"name": "por-defecto",
"classes": "mt-base",
"fieldset": {
"legend": {
"text": "Selecciona organismo"
}
},
"idPrefix": "default-example",
"items": [
{
"text": "Item 1",
"id": "default-example-item-1",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1"
},
{
"text": "Subitem 2",
"value": "subitem-2"
},
{
"text": "Subitem 3",
"value": "subitem-3"
}
],
"attributes": {
"aria-labelledby": "default-example-item-1"
}
}
},
{
"text": "Item 2",
"id": "default-example-item-2",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1"
},
{
"text": "Subitem 2",
"value": "subitem-2"
},
{
"text": "Subitem 3",
"value": "subitem-3"
}
],
"attributes": {
"aria-labelledby": "default-example-item-2"
}
}
},
{
"text": "Item 3",
"id": "default-example-item-3",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1"
},
{
"text": "Subitem 2",
"value": "subitem-2"
},
{
"text": "Subitem 3",
"value": "subitem-3"
}
],
"attributes": {
"aria-labelledby": "default-example-item-3"
}
}
}
]
}) }}
HTML
<!-- tree -->
<div class="c-form-group">
<!-- fieldset -->
<fieldset>
<legend class="font-bold">
Selecciona organismo
</legend>
<ul class="c-tree mt-base" id="default-example" role="tree" data-module="c-tree">
<li id="default-example-item-1" class="c-tree__item ml-4 focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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-example-item-1-input" name="por-defecto" type="radio" value="">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="default-example-item-1-input">Item 1</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="default-example-item-1">
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-default-example-item-1-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-default-example-item-1-0-input" name="por-defecto" type="radio" value="subitem-1">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-default-example-item-1-0-input">Subitem 1</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-default-example-item-1-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-default-example-item-1-1-input" name="por-defecto" type="radio" value="subitem-2">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-default-example-item-1-1-input">Subitem 2</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-default-example-item-1-2" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-default-example-item-1-2-input" name="por-defecto" type="radio" value="subitem-3">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-default-example-item-1-2-input">Subitem 3</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
</ul>
</li>
<li id="default-example-item-2" class="c-tree__item ml-4 focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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-example-item-2-input" name="por-defecto" type="radio" value="">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="default-example-item-2-input">Item 2</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="default-example-item-2">
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-default-example-item-2-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-default-example-item-2-0-input" name="por-defecto" type="radio" value="subitem-1">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-default-example-item-2-0-input">Subitem 1</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-default-example-item-2-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-default-example-item-2-1-input" name="por-defecto" type="radio" value="subitem-2">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-default-example-item-2-1-input">Subitem 2</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-default-example-item-2-2" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-default-example-item-2-2-input" name="por-defecto" type="radio" value="subitem-3">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-default-example-item-2-2-input">Subitem 3</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
</ul>
</li>
<li id="default-example-item-3" class="c-tree__item ml-4 focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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-example-item-3-input" name="por-defecto" type="radio" value="">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="default-example-item-3-input">Item 3</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="default-example-item-3">
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-default-example-item-3-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-default-example-item-3-0-input" name="por-defecto" type="radio" value="subitem-1">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-default-example-item-3-0-input">Subitem 1</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-default-example-item-3-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-default-example-item-3-1-input" name="por-defecto" type="radio" value="subitem-2">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-default-example-item-3-1-input">Subitem 2</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-default-example-item-3-2" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-default-example-item-3-2-input" name="por-defecto" type="radio" value="subitem-3">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-default-example-item-3-2-input">Subitem 3</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
</ul>
</li>
</ul>
</fieldset>
<!-- /fieldset -->
</div>
<!-- /tree -->
Tipo checkbox #
Mostrar códigodel ejemplo: Tipo checkbox
Contenido
Nunjucks macro
{% from "components/tree/_macro.tree.njk" import componentTree %}
{{ componentTree({
"name": "type-checkbox",
"classes": "mt-base",
"type": "checkbox",
"fieldset": {
"legend": {
"text": "Selecciona organismo"
}
},
"idPrefix": "type-checkbox",
"items": [
{
"text": "Item 1",
"id": "type-checkbox-example-item-1",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1"
},
{
"text": "Subitem 2",
"value": "subitem-2"
},
{
"text": "Subitem 3",
"value": "subitem-3"
}
],
"attributes": {
"aria-labelledby": "type-checkbox-example-item-1"
}
}
},
{
"text": "Item 2",
"id": "type-checkbox-example-item-2",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1"
},
{
"text": "Subitem 2",
"value": "subitem-2"
},
{
"text": "Subitem 3",
"value": "subitem-3"
}
],
"attributes": {
"aria-labelledby": "type-checkbox-example-item-2"
}
}
},
{
"text": "Item 3",
"id": "type-checkbox-example-item-3",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1"
},
{
"text": "Subitem 2",
"value": "subitem-2"
},
{
"text": "Subitem 3",
"value": "subitem-3"
}
],
"attributes": {
"aria-labelledby": "type-checkbox-example-item-3"
}
}
}
]
}) }}
HTML
<!-- tree -->
<div class="c-form-group">
<!-- fieldset -->
<fieldset>
<legend class="font-bold">
Selecciona organismo
</legend>
<ul class="c-tree mt-base" id="type-checkbox" role="tree" data-module="c-tree">
<li id="type-checkbox-example-item-1" class="c-tree__item ml-4 focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="type-checkbox-example-item-1-input" name="type-checkbox" type="checkbox" value="">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="type-checkbox-example-item-1-input">Item 1</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="type-checkbox-example-item-1">
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-type-checkbox-example-item-1-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-type-checkbox-example-item-1-0-input" name="type-checkbox" type="checkbox" value="subitem-1">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-type-checkbox-example-item-1-0-input">Subitem 1</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-type-checkbox-example-item-1-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-type-checkbox-example-item-1-1-input" name="type-checkbox" type="checkbox" value="subitem-2">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-type-checkbox-example-item-1-1-input">Subitem 2</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-type-checkbox-example-item-1-2" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-type-checkbox-example-item-1-2-input" name="type-checkbox" type="checkbox" value="subitem-3">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-type-checkbox-example-item-1-2-input">Subitem 3</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
</ul>
</li>
<li id="type-checkbox-example-item-2" class="c-tree__item ml-4 focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="type-checkbox-example-item-2-input" name="type-checkbox" type="checkbox" value="">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="type-checkbox-example-item-2-input">Item 2</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="type-checkbox-example-item-2">
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-type-checkbox-example-item-2-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-type-checkbox-example-item-2-0-input" name="type-checkbox" type="checkbox" value="subitem-1">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-type-checkbox-example-item-2-0-input">Subitem 1</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-type-checkbox-example-item-2-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-type-checkbox-example-item-2-1-input" name="type-checkbox" type="checkbox" value="subitem-2">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-type-checkbox-example-item-2-1-input">Subitem 2</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-type-checkbox-example-item-2-2" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-type-checkbox-example-item-2-2-input" name="type-checkbox" type="checkbox" value="subitem-3">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-type-checkbox-example-item-2-2-input">Subitem 3</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
</ul>
</li>
<li id="type-checkbox-example-item-3" class="c-tree__item ml-4 focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="type-checkbox-example-item-3-input" name="type-checkbox" type="checkbox" value="">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="type-checkbox-example-item-3-input">Item 3</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="type-checkbox-example-item-3">
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-type-checkbox-example-item-3-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-type-checkbox-example-item-3-0-input" name="type-checkbox" type="checkbox" value="subitem-1">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-type-checkbox-example-item-3-0-input">Subitem 1</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-type-checkbox-example-item-3-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-type-checkbox-example-item-3-1-input" name="type-checkbox" type="checkbox" value="subitem-2">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-type-checkbox-example-item-3-1-input">Subitem 2</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-type-checkbox-example-item-3-2" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-type-checkbox-example-item-3-2-input" name="type-checkbox" type="checkbox" value="subitem-3">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-type-checkbox-example-item-3-2-input">Subitem 3</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
</ul>
</li>
</ul>
</fieldset>
<!-- /fieldset -->
</div>
<!-- /tree -->
Tree navigation #
Mostrar códigodel ejemplo: Tree navigation
Contenido
Nunjucks macro
{% from "components/tree/_macro.tree.njk" import componentTree %}
{{ componentTree({
"name": "tree-nav",
"classes": "mt-base",
"type": "navigation",
"idPrefix": "navigation-example",
"ariaLabel": "Apartados de esta página",
"items": [
{
"text": "Item 1",
"id": "navigation-example-item-1",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1",
"href": "#"
},
{
"text": "Subitem 2",
"value": "subitem-2",
"href": "#"
},
{
"text": "Subitem 3",
"value": "subitem-3",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1",
"href": "#"
},
{
"text": "Subitem 2",
"value": "subitem-2",
"href": "#"
},
{
"text": "Subitem 3",
"value": "subitem-3",
"href": "#",
"active": true
}
],
"attributes": {
"aria-labelledby": "navigation-example-item-3"
}
}
}
],
"attributes": {
"aria-labelledby": "navigation-example-item-1"
}
}
},
{
"text": "Item 2",
"id": "navigation-example-item-2",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1",
"href": "#"
},
{
"text": "Subitem 2",
"value": "subitem-2",
"href": "#"
},
{
"text": "Subitem 3",
"value": "subitem-3",
"href": "#"
}
],
"attributes": {
"aria-labelledby": "navigation-example-item-2"
}
}
},
{
"text": "Item 3",
"id": "navigation-example-item-3",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1",
"href": "#"
},
{
"text": "Subitem 2",
"value": "subitem-2",
"href": "#"
},
{
"text": "Subitem 3",
"value": "subitem-3",
"href": "#"
}
],
"attributes": {
"aria-labelledby": "navigation-example-item-3"
}
}
}
]
}) }}
HTML
<!-- tree -->
<div class="c-form-group">
<nav aria-label="Apartados de esta página">
<ul class="c-tree mt-base" id="navigation-example" role="tree" data-tree-navigation data-module="c-tree">
<li id="navigation-example-item-1" class="c-tree__item ml-4 my-sm focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<span id="navigation-example-item-1-link" class="block px-xs">
Item 1
</span>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="navigation-example-item-1">
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-navigation-example-item-1-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-navigation-example-item-1-0-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black hover:text-primary-base hover:underline">
Subitem 1
</a>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-navigation-example-item-1-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-navigation-example-item-1-1-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black hover:text-primary-base hover:underline">
Subitem 2
</a>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-navigation-example-item-1-2" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<span id="sub-navigation-example-item-1-2-link" class="block px-xs">
Subitem 3
</span>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="navigation-example-item-3">
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-sub-navigation-example-item-1-2-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-sub-navigation-example-item-1-2-0-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black hover:text-primary-base hover:underline">
Subitem 1
</a>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-sub-navigation-example-item-1-2-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-sub-navigation-example-item-1-2-1-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black hover:text-primary-base hover:underline">
Subitem 2
</a>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-sub-navigation-example-item-1-2-2" role="treeitem" data-module="c-tree__item">
<div class="block font-bold" aria-current="page">
<div class="font-bold">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-sub-navigation-example-item-1-2-2-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black hover:text-primary-base hover:underline" aria-current="page">
<strong class="font-bold">Subitem 3</strong>
</a>
</div>
</div>
</div>
</div>
</li>
</ul>
</li>
</ul>
</li>
<li id="navigation-example-item-2" class="c-tree__item ml-4 my-sm focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<span id="navigation-example-item-2-link" class="block px-xs">
Item 2
</span>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="navigation-example-item-2">
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-navigation-example-item-2-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-navigation-example-item-2-0-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black hover:text-primary-base hover:underline">
Subitem 1
</a>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-navigation-example-item-2-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-navigation-example-item-2-1-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black hover:text-primary-base hover:underline">
Subitem 2
</a>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-navigation-example-item-2-2" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-navigation-example-item-2-2-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black hover:text-primary-base hover:underline">
Subitem 3
</a>
</div>
</div>
</div>
</li>
</ul>
</li>
<li id="navigation-example-item-3" class="c-tree__item ml-4 my-sm focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<span id="navigation-example-item-3-link" class="block px-xs">
Item 3
</span>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="navigation-example-item-3">
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-navigation-example-item-3-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-navigation-example-item-3-0-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black hover:text-primary-base hover:underline">
Subitem 1
</a>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-navigation-example-item-3-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-navigation-example-item-3-1-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black hover:text-primary-base hover:underline">
Subitem 2
</a>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-navigation-example-item-3-2" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-navigation-example-item-3-2-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black hover:text-primary-base hover:underline">
Subitem 3
</a>
</div>
</div>
</div>
</li>
</ul>
</li>
</ul>
</nav>
</div>
<!-- /tree -->
Tree navigation con hasunderline #
Usa "hasUnderline": true
cuando tienes mezclados, items deshabilitados o sin href e items normales.
Mostrar códigodel ejemplo: Tree navigation con hasunderline
Contenido
Nunjucks macro
{% from "components/tree/_macro.tree.njk" import componentTree %}
{{ componentTree({
"name": "tree-nav-hasunderline",
"classes": "mt-base",
"type": "navigation",
"idPrefix": "navigation-hasunderline-example",
"ariaLabel": "Apartados de esta página",
"hasUnderline": "true",
"items": [
{
"text": "Item 1",
"id": "navigation-hasunderline-example-item-1",
"href": "#",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1",
"href": "#"
},
{
"text": "Subitem 2 deshabilitado o sin href",
"value": "subitem-2",
"href": "#",
"disabled": true
},
{
"text": "Subitem 3",
"value": "subitem-3",
"href": "#",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1",
"href": "#"
},
{
"text": "Subitem 2",
"value": "subitem-2",
"href": "#"
},
{
"text": "Subitem 3",
"value": "subitem-3",
"href": "#",
"active": true
}
],
"attributes": {
"aria-labelledby": "navigation-hasunderline-example-item-3"
}
}
}
],
"attributes": {
"aria-labelledby": "navigation-hasunderline-example-item-1"
}
}
},
{
"text": "Item 2 deshabilitado o sin href",
"id": "navigation-hasunderline-example-item-2",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1",
"href": "#"
},
{
"text": "Subitem 2 deshabilitado o sin href",
"value": "subitem-2",
"href": "#",
"disabled": true
},
{
"text": "Subitem 3",
"value": "subitem-3",
"href": "#"
}
],
"attributes": {
"aria-labelledby": "navigation-hasunderline-example-item-2"
}
}
},
{
"text": "Item 3",
"id": "navigation-hasunderline-example-item-3",
"href": "#",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1",
"href": "#"
},
{
"text": "Subitem 2",
"value": "subitem-2",
"href": "#"
},
{
"text": "Subitem 3",
"value": "subitem-3",
"href": "#"
}
],
"attributes": {
"aria-labelledby": "navigation-hasunderline-example-item-3"
}
}
}
]
}) }}
HTML
<!-- tree -->
<div class="c-form-group">
<nav aria-label="Apartados de esta página">
<ul class="c-tree mt-base" id="navigation-hasunderline-example" role="tree" data-tree-navigation data-module="c-tree">
<li id="navigation-hasunderline-example-item-1" class="c-tree__item ml-4 my-sm focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<a id="navigation-hasunderline-example-item-1-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black underline hover:text-primary-base hover:underline">
Item 1
</a>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="navigation-hasunderline-example-item-1">
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-navigation-hasunderline-example-item-1-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-navigation-hasunderline-example-item-1-0-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black underline hover:text-primary-base hover:underline">
Subitem 1
</a>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-navigation-hasunderline-example-item-1-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-navigation-hasunderline-example-item-1-1-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black underline no-underline pointer-events-none" aria-disabled="true" tabindex="-1">
Subitem 2 deshabilitado o sin href
</a>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-navigation-hasunderline-example-item-1-2" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<a id="sub-navigation-hasunderline-example-item-1-2-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black underline hover:text-primary-base hover:underline">
Subitem 3
</a>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="navigation-hasunderline-example-item-3">
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-sub-navigation-hasunderline-example-item-1-2-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-sub-navigation-hasunderline-example-item-1-2-0-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black underline hover:text-primary-base hover:underline">
Subitem 1
</a>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-sub-navigation-hasunderline-example-item-1-2-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-sub-navigation-hasunderline-example-item-1-2-1-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black underline hover:text-primary-base hover:underline">
Subitem 2
</a>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-sub-navigation-hasunderline-example-item-1-2-2" role="treeitem" data-module="c-tree__item">
<div class="block font-bold" aria-current="page">
<div class="font-bold">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-sub-navigation-hasunderline-example-item-1-2-2-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black underline hover:text-primary-base hover:underline" aria-current="page">
<strong class="font-bold">Subitem 3</strong>
</a>
</div>
</div>
</div>
</div>
</li>
</ul>
</li>
</ul>
</li>
<li id="navigation-hasunderline-example-item-2" class="c-tree__item ml-4 my-sm focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<span id="navigation-hasunderline-example-item-2-link" class="block px-xs">
Item 2 deshabilitado o sin href
</span>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="navigation-hasunderline-example-item-2">
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-navigation-hasunderline-example-item-2-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-navigation-hasunderline-example-item-2-0-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black underline hover:text-primary-base hover:underline">
Subitem 1
</a>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-navigation-hasunderline-example-item-2-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-navigation-hasunderline-example-item-2-1-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black underline no-underline pointer-events-none" aria-disabled="true" tabindex="-1">
Subitem 2 deshabilitado o sin href
</a>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-navigation-hasunderline-example-item-2-2" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-navigation-hasunderline-example-item-2-2-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black underline hover:text-primary-base hover:underline">
Subitem 3
</a>
</div>
</div>
</div>
</li>
</ul>
</li>
<li id="navigation-hasunderline-example-item-3" class="c-tree__item ml-4 my-sm focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<a id="navigation-hasunderline-example-item-3-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black underline hover:text-primary-base hover:underline">
Item 3
</a>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="navigation-hasunderline-example-item-3">
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-navigation-hasunderline-example-item-3-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-navigation-hasunderline-example-item-3-0-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black underline hover:text-primary-base hover:underline">
Subitem 1
</a>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-navigation-hasunderline-example-item-3-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-navigation-hasunderline-example-item-3-1-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black underline hover:text-primary-base hover:underline">
Subitem 2
</a>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-navigation-hasunderline-example-item-3-2" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-navigation-hasunderline-example-item-3-2-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black underline hover:text-primary-base hover:underline">
Subitem 3
</a>
</div>
</div>
</div>
</li>
</ul>
</li>
</ul>
</nav>
</div>
<!-- /tree -->
Tree navigation link #
Usa el parámetro "classes": "c-link"
en cada item para dar apariencia más visible de links.
Mostrar códigodel ejemplo: Tree navigation link
Contenido
Nunjucks macro
{% from "components/tree/_macro.tree.njk" import componentTree %}
{{ componentTree({
"name": "tree-nav-link",
"classes": "mt-base",
"type": "navigation",
"idPrefix": "navigation-link-example",
"ariaLabel": "Apartados de esta página",
"items": [
{
"text": "Item 1",
"id": "navigation-link-example-item-1",
"classes": "c-link",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1",
"href": "#",
"classes": "c-link"
},
{
"text": "Subitem 2",
"value": "subitem-2",
"href": "#",
"classes": "c-link"
},
{
"text": "Subitem 3",
"value": "subitem-3",
"classes": "c-link",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1",
"href": "#",
"classes": "c-link"
},
{
"text": "Subitem 2",
"value": "subitem-2",
"href": "#",
"classes": "c-link"
},
{
"text": "Subitem 3",
"value": "subitem-3",
"href": "#",
"active": true,
"classes": "c-link"
}
],
"attributes": {
"aria-labelledby": "navigation-link-example-item-3"
}
}
}
],
"attributes": {
"aria-labelledby": "navigation-link-example-item-1"
}
}
},
{
"text": "Item 2",
"classes": "c-link",
"id": "navigation-link-example-item-2",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1",
"href": "#",
"classes": "c-link"
},
{
"text": "Subitem 2",
"value": "subitem-2",
"href": "#",
"classes": "c-link"
},
{
"text": "Subitem 3",
"value": "subitem-3",
"href": "#",
"classes": "c-link"
}
],
"attributes": {
"aria-labelledby": "navigation-link-example-item-2"
}
}
},
{
"text": "Item 3",
"classes": "c-link",
"id": "navigation-link-example-item-3",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1",
"href": "#",
"classes": "c-link"
},
{
"text": "Subitem 2",
"value": "subitem-2",
"href": "#",
"classes": "c-link"
},
{
"text": "Subitem 3",
"value": "subitem-3",
"href": "#",
"classes": "c-link"
}
],
"attributes": {
"aria-labelledby": "navigation-link-example-item-3"
}
}
}
]
}) }}
HTML
<!-- tree -->
<div class="c-form-group">
<nav aria-label="Apartados de esta página">
<ul class="c-tree mt-base" id="navigation-link-example" role="tree" data-tree-navigation data-module="c-tree">
<li id="navigation-link-example-item-1" class="c-tree__item ml-4 my-sm focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left c-link">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div class=" c-link">
<div class="relative flex items-start py-xs">
<span id="navigation-link-example-item-1-link" class="block px-xs c-link">
Item 1
</span>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="navigation-link-example-item-1">
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-navigation-link-example-item-1-0" role="treeitem" data-module="c-tree__item">
<div class="block c-link">
<div class=" c-link">
<div class="relative flex items-start py-xs">
<a id="sub-navigation-link-example-item-1-0-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black c-link hover:text-primary-base hover:underline">
Subitem 1
</a>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-navigation-link-example-item-1-1" role="treeitem" data-module="c-tree__item">
<div class="block c-link">
<div class=" c-link">
<div class="relative flex items-start py-xs">
<a id="sub-navigation-link-example-item-1-1-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black c-link hover:text-primary-base hover:underline">
Subitem 2
</a>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-navigation-link-example-item-1-2" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left c-link">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div class=" c-link">
<div class="relative flex items-start py-xs">
<span id="sub-navigation-link-example-item-1-2-link" class="block px-xs c-link">
Subitem 3
</span>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="navigation-link-example-item-3">
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-sub-navigation-link-example-item-1-2-0" role="treeitem" data-module="c-tree__item">
<div class="block c-link">
<div class=" c-link">
<div class="relative flex items-start py-xs">
<a id="sub-sub-navigation-link-example-item-1-2-0-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black c-link hover:text-primary-base hover:underline">
Subitem 1
</a>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-sub-navigation-link-example-item-1-2-1" role="treeitem" data-module="c-tree__item">
<div class="block c-link">
<div class=" c-link">
<div class="relative flex items-start py-xs">
<a id="sub-sub-navigation-link-example-item-1-2-1-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black c-link hover:text-primary-base hover:underline">
Subitem 2
</a>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-sub-navigation-link-example-item-1-2-2" role="treeitem" data-module="c-tree__item">
<div class="block c-link font-bold" aria-current="page">
<div class="font-bold">
<div class=" c-link">
<div class="relative flex items-start py-xs">
<a id="sub-sub-navigation-link-example-item-1-2-2-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black c-link hover:text-primary-base hover:underline" aria-current="page">
<strong class="font-bold">Subitem 3</strong>
</a>
</div>
</div>
</div>
</div>
</li>
</ul>
</li>
</ul>
</li>
<li id="navigation-link-example-item-2" class="c-tree__item ml-4 my-sm focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left c-link">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div class=" c-link">
<div class="relative flex items-start py-xs">
<span id="navigation-link-example-item-2-link" class="block px-xs c-link">
Item 2
</span>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="navigation-link-example-item-2">
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-navigation-link-example-item-2-0" role="treeitem" data-module="c-tree__item">
<div class="block c-link">
<div class=" c-link">
<div class="relative flex items-start py-xs">
<a id="sub-navigation-link-example-item-2-0-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black c-link hover:text-primary-base hover:underline">
Subitem 1
</a>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-navigation-link-example-item-2-1" role="treeitem" data-module="c-tree__item">
<div class="block c-link">
<div class=" c-link">
<div class="relative flex items-start py-xs">
<a id="sub-navigation-link-example-item-2-1-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black c-link hover:text-primary-base hover:underline">
Subitem 2
</a>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-navigation-link-example-item-2-2" role="treeitem" data-module="c-tree__item">
<div class="block c-link">
<div class=" c-link">
<div class="relative flex items-start py-xs">
<a id="sub-navigation-link-example-item-2-2-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black c-link hover:text-primary-base hover:underline">
Subitem 3
</a>
</div>
</div>
</div>
</li>
</ul>
</li>
<li id="navigation-link-example-item-3" class="c-tree__item ml-4 my-sm focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left c-link">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div class=" c-link">
<div class="relative flex items-start py-xs">
<span id="navigation-link-example-item-3-link" class="block px-xs c-link">
Item 3
</span>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="navigation-link-example-item-3">
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-navigation-link-example-item-3-0" role="treeitem" data-module="c-tree__item">
<div class="block c-link">
<div class=" c-link">
<div class="relative flex items-start py-xs">
<a id="sub-navigation-link-example-item-3-0-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black c-link hover:text-primary-base hover:underline">
Subitem 1
</a>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-navigation-link-example-item-3-1" role="treeitem" data-module="c-tree__item">
<div class="block c-link">
<div class=" c-link">
<div class="relative flex items-start py-xs">
<a id="sub-navigation-link-example-item-3-1-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black c-link hover:text-primary-base hover:underline">
Subitem 2
</a>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-navigation-link-example-item-3-2" role="treeitem" data-module="c-tree__item">
<div class="block c-link">
<div class=" c-link">
<div class="relative flex items-start py-xs">
<a id="sub-navigation-link-example-item-3-2-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black c-link hover:text-primary-base hover:underline">
Subitem 3
</a>
</div>
</div>
</div>
</li>
</ul>
</li>
</ul>
</nav>
</div>
<!-- /tree -->
Tree nav: mostrar activo un item del tree con javascript #
Puedes usar con javascript la función global activateItemsTree(tree, element, true)
, para mostrar un item activo del tree nav. Ej: Abre la consola del navegador y escribe activateItemsTree("tree-nav-js", "sub-sub-tree-nav-js-item-1-2-1", true)
para mostrar un item del menú activo.
Mostrar códigodel ejemplo: Tree nav: mostrar activo un item del tree con javascript
Contenido
Nunjucks macro
{% from "components/tree/_macro.tree.njk" import componentTree %}
{{ componentTree({
"name": "tree-navigation-js",
"classes": "mt-base",
"id": "tree-nav-js",
"type": "navigation",
"idPrefix": "tree-nav-js-example",
"items": [
{
"text": "Item 1",
"id": "tree-nav-js-item-1",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1",
"href": "index.html"
},
{
"text": "Subitem 2",
"value": "subitem-2",
"href": "#"
},
{
"text": "Subitem 3",
"value": "subitem-3",
"href": "#",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1",
"href": "#"
},
{
"text": "Subitem 2",
"value": "subitem-2",
"href": "#"
},
{
"text": "Subitem 3",
"value": "subitem-3",
"href": "#"
}
],
"attributes": {
"aria-labelledby": "tree-nav-js-item-3"
}
}
}
],
"attributes": {
"aria-labelledby": "tree-nav-js-item-1"
}
}
},
{
"text": "Item 2",
"id": "tree-nav-js-item-2",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1",
"href": "#"
},
{
"text": "Subitem 2",
"value": "subitem-2",
"href": "#"
},
{
"text": "Subitem 3",
"value": "subitem-3",
"href": "#"
}
],
"attributes": {
"aria-labelledby": "tree-nav-js-item-2"
}
}
},
{
"text": "Item 3",
"id": "tree-nav-js-item-3",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1",
"href": "#"
},
{
"text": "Subitem 2",
"value": "subitem-2",
"href": "#"
},
{
"text": "Subitem 3",
"value": "subitem-3",
"href": "#"
}
],
"attributes": {
"aria-labelledby": "tree-nav-js-item-3"
}
}
}
]
}) }}
HTML
<!-- tree -->
<div class="c-form-group">
<nav aria-label="Árbol de navegación">
<ul class="c-tree mt-base" id="tree-nav-js" role="tree" data-tree-navigation data-module="c-tree">
<li id="tree-nav-js-item-1" class="c-tree__item ml-4 my-sm focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<span id="tree-nav-js-item-1-link" class="block px-xs">
Item 1
</span>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="tree-nav-js-item-1">
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-tree-nav-js-item-1-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-tree-nav-js-item-1-0-link" href="index.html" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black hover:text-primary-base hover:underline">
Subitem 1
</a>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-tree-nav-js-item-1-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-tree-nav-js-item-1-1-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black hover:text-primary-base hover:underline">
Subitem 2
</a>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-tree-nav-js-item-1-2" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<a id="sub-tree-nav-js-item-1-2-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black hover:text-primary-base hover:underline">
Subitem 3
</a>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="tree-nav-js-item-3">
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-sub-tree-nav-js-item-1-2-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-sub-tree-nav-js-item-1-2-0-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black hover:text-primary-base hover:underline">
Subitem 1
</a>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-sub-tree-nav-js-item-1-2-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-sub-tree-nav-js-item-1-2-1-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black hover:text-primary-base hover:underline">
Subitem 2
</a>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-sub-tree-nav-js-item-1-2-2" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-sub-tree-nav-js-item-1-2-2-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black hover:text-primary-base hover:underline">
Subitem 3
</a>
</div>
</div>
</div>
</li>
</ul>
</li>
</ul>
</li>
<li id="tree-nav-js-item-2" class="c-tree__item ml-4 my-sm focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<span id="tree-nav-js-item-2-link" class="block px-xs">
Item 2
</span>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="tree-nav-js-item-2">
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-tree-nav-js-item-2-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-tree-nav-js-item-2-0-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black hover:text-primary-base hover:underline">
Subitem 1
</a>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-tree-nav-js-item-2-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-tree-nav-js-item-2-1-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black hover:text-primary-base hover:underline">
Subitem 2
</a>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-tree-nav-js-item-2-2" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-tree-nav-js-item-2-2-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black hover:text-primary-base hover:underline">
Subitem 3
</a>
</div>
</div>
</div>
</li>
</ul>
</li>
<li id="tree-nav-js-item-3" class="c-tree__item ml-4 my-sm focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<span id="tree-nav-js-item-3-link" class="block px-xs">
Item 3
</span>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="tree-nav-js-item-3">
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-tree-nav-js-item-3-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-tree-nav-js-item-3-0-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black hover:text-primary-base hover:underline">
Subitem 1
</a>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-tree-nav-js-item-3-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-tree-nav-js-item-3-1-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black hover:text-primary-base hover:underline">
Subitem 2
</a>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-5 my-sm origin-top-left focus:outline-none" id="sub-tree-nav-js-item-3-2" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<a id="sub-tree-nav-js-item-3-2-link" href="#" class="block px-xs focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black hover:text-primary-base hover:underline">
Subitem 3
</a>
</div>
</div>
</div>
</li>
</ul>
</li>
</ul>
</nav>
</div>
<!-- /tree -->
Con pista y error #
Mostrar códigodel ejemplo: Con pista y error
Contenido
Nunjucks macro
{% from "components/tree/_macro.tree.njk" import componentTree %}
{{ componentTree({
"name": "with-hint-and-error",
"classes": "mt-base",
"fieldset": {
"legend": {
"text": "Selecciona organismo"
}
},
"hint": {
"text": "Selecciona el organismo al que perteneces."
},
"errorMessage": {
"text": "Error: No tienes permiso para seleccionar ese organismo."
},
"idPrefix": "with-hint-and-error",
"items": [
{
"text": "Item 1",
"id": "with-hint-and-error-example-item-1",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1"
},
{
"text": "Subitem 2",
"value": "subitem-2"
},
{
"text": "Subitem 3",
"value": "subitem-3"
}
],
"attributes": {
"aria-labelledby": "with-hint-and-error-example-item-1"
}
}
},
{
"text": "Item 2",
"id": "with-hint-and-error-example-item-2",
"checked": true,
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1"
},
{
"text": "Subitem 2",
"value": "subitem-2"
},
{
"text": "Subitem 3",
"value": "subitem-3"
}
],
"attributes": {
"aria-labelledby": "with-hint-and-error-example-item-2"
}
}
},
{
"text": "Item 3",
"id": "with-hint-and-error-example-item-3",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1"
},
{
"text": "Subitem 2",
"value": "subitem-2"
},
{
"text": "Subitem 3",
"value": "subitem-3"
}
],
"attributes": {
"aria-labelledby": "with-hint-and-error-example-item-3"
}
}
}
]
}) }}
HTML
<!-- tree -->
<div class="c-form-group c-form-group--error">
<!-- fieldset -->
<fieldset aria-describedby="with-hint-and-error-hint with-hint-and-error-error" aria-errormessage="with-hint-and-error-error">
<legend class="font-bold">
Selecciona organismo
</legend>
<!-- hint -->
<p id="with-hint-and-error-hint" class="block text-neutral-dark">Selecciona el organismo al que perteneces.</p>
<!-- /hint -->
<!-- error-message -->
<p id="with-hint-and-error-error" class="block font-semibold text-alert-base">
<span class="sr-only">Error:</span>Error: No tienes permiso para seleccionar ese organismo.
</p>
<!-- /error-message -->
<ul class="c-tree mt-base" id="with-hint-and-error" role="tree" data-module="c-tree">
<li id="with-hint-and-error-example-item-1" class="c-tree__item ml-4 focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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-hint-and-error-example-item-1-input" name="with-hint-and-error" type="radio" value="" aria-invalid="true">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="with-hint-and-error-example-item-1-input">Item 1</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="with-hint-and-error-example-item-1">
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-hint-and-error-example-item-1-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-hint-and-error-example-item-1-0-input" name="with-hint-and-error" type="radio" value="subitem-1" aria-invalid="true">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-hint-and-error-example-item-1-0-input">Subitem 1</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-hint-and-error-example-item-1-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-hint-and-error-example-item-1-1-input" name="with-hint-and-error" type="radio" value="subitem-2" aria-invalid="true">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-hint-and-error-example-item-1-1-input">Subitem 2</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-hint-and-error-example-item-1-2" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-hint-and-error-example-item-1-2-input" name="with-hint-and-error" type="radio" value="subitem-3" aria-invalid="true">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-hint-and-error-example-item-1-2-input">Subitem 3</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
</ul>
</li>
<li id="with-hint-and-error-example-item-2" class="c-tree__item ml-4 focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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-hint-and-error-example-item-2-input" name="with-hint-and-error" type="radio" value="" checked aria-invalid="true">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="with-hint-and-error-example-item-2-input">Item 2</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="with-hint-and-error-example-item-2">
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-hint-and-error-example-item-2-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-hint-and-error-example-item-2-0-input" name="with-hint-and-error" type="radio" value="subitem-1" aria-invalid="true">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-hint-and-error-example-item-2-0-input">Subitem 1</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-hint-and-error-example-item-2-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-hint-and-error-example-item-2-1-input" name="with-hint-and-error" type="radio" value="subitem-2" aria-invalid="true">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-hint-and-error-example-item-2-1-input">Subitem 2</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-hint-and-error-example-item-2-2" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-hint-and-error-example-item-2-2-input" name="with-hint-and-error" type="radio" value="subitem-3" aria-invalid="true">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-hint-and-error-example-item-2-2-input">Subitem 3</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
</ul>
</li>
<li id="with-hint-and-error-example-item-3" class="c-tree__item ml-4 focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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-hint-and-error-example-item-3-input" name="with-hint-and-error" type="radio" value="" aria-invalid="true">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="with-hint-and-error-example-item-3-input">Item 3</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="with-hint-and-error-example-item-3">
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-hint-and-error-example-item-3-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-hint-and-error-example-item-3-0-input" name="with-hint-and-error" type="radio" value="subitem-1" aria-invalid="true">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-hint-and-error-example-item-3-0-input">Subitem 1</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-hint-and-error-example-item-3-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-hint-and-error-example-item-3-1-input" name="with-hint-and-error" type="radio" value="subitem-2" aria-invalid="true">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-hint-and-error-example-item-3-1-input">Subitem 2</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-hint-and-error-example-item-3-2" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-hint-and-error-example-item-3-2-input" name="with-hint-and-error" type="radio" value="subitem-3" aria-invalid="true">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-hint-and-error-example-item-3-2-input">Subitem 3</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
</ul>
</li>
</ul>
</fieldset>
<!-- /fieldset -->
</div>
<!-- /tree -->
Con item deshabilitado #
Mostrar códigodel ejemplo: Con item deshabilitado
Contenido
Nunjucks macro
{% from "components/tree/_macro.tree.njk" import componentTree %}
{{ componentTree({
"name": "with-disabled-item",
"classes": "mt-base",
"fieldset": {
"legend": {
"text": "Selecciona organismo"
}
},
"hint": {
"text": "Selecciona el organismo al que perteneces."
},
"idPrefix": "with-disabled-item",
"items": [
{
"text": "Item 1",
"id": "with-disabled-item-example-item-1",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1"
},
{
"text": "Subitem 2",
"value": "subitem-2"
},
{
"text": "Subitem 3",
"value": "subitem-3"
}
],
"attributes": {
"aria-labelledby": "with-disabled-item-example-item-1"
}
}
},
{
"text": "Item 2",
"id": "with-disabled-item-example-item-2",
"disabled": true,
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1"
},
{
"text": "Subitem 2",
"value": "subitem-2",
"disabled": true
},
{
"text": "Subitem 3",
"value": "subitem-3"
}
],
"attributes": {
"aria-labelledby": "with-disabled-item-example-item-2"
}
}
},
{
"text": "Item 3",
"id": "with-disabled-item-example-item-3",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1"
},
{
"text": "Subitem 2",
"value": "subitem-2"
},
{
"text": "Subitem 3",
"value": "subitem-3"
}
],
"attributes": {
"aria-labelledby": "with-disabled-item-example-item-3"
}
}
}
]
}) }}
HTML
<!-- tree -->
<div class="c-form-group">
<!-- fieldset -->
<fieldset aria-describedby="with-disabled-item-hint">
<legend class="font-bold">
Selecciona organismo
</legend>
<!-- hint -->
<p id="with-disabled-item-hint" class="block text-neutral-dark">Selecciona el organismo al que perteneces.</p>
<!-- /hint -->
<ul class="c-tree mt-base" id="with-disabled-item" role="tree" data-module="c-tree">
<li id="with-disabled-item-example-item-1" class="c-tree__item ml-4 focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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-disabled-item-example-item-1-input" name="with-disabled-item" type="radio" value="">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="with-disabled-item-example-item-1-input">Item 1</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="with-disabled-item-example-item-1">
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-disabled-item-example-item-1-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-disabled-item-example-item-1-0-input" name="with-disabled-item" type="radio" value="subitem-1">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-disabled-item-example-item-1-0-input">Subitem 1</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-disabled-item-example-item-1-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-disabled-item-example-item-1-1-input" name="with-disabled-item" type="radio" value="subitem-2">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-disabled-item-example-item-1-1-input">Subitem 2</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-disabled-item-example-item-1-2" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-disabled-item-example-item-1-2-input" name="with-disabled-item" type="radio" value="subitem-3">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-disabled-item-example-item-1-2-input">Subitem 3</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
</ul>
</li>
<li id="with-disabled-item-example-item-2" class="c-tree__item ml-4 focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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-disabled-item-example-item-2-input" name="with-disabled-item" type="radio" value="" disabled>
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="with-disabled-item-example-item-2-input">Item 2</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="with-disabled-item-example-item-2">
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-disabled-item-example-item-2-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-disabled-item-example-item-2-0-input" name="with-disabled-item" type="radio" value="subitem-1">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-disabled-item-example-item-2-0-input">Subitem 1</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-disabled-item-example-item-2-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-disabled-item-example-item-2-1-input" name="with-disabled-item" type="radio" value="subitem-2" disabled>
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-disabled-item-example-item-2-1-input">Subitem 2</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-disabled-item-example-item-2-2" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-disabled-item-example-item-2-2-input" name="with-disabled-item" type="radio" value="subitem-3">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-disabled-item-example-item-2-2-input">Subitem 3</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
</ul>
</li>
<li id="with-disabled-item-example-item-3" class="c-tree__item ml-4 focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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-disabled-item-example-item-3-input" name="with-disabled-item" type="radio" value="">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="with-disabled-item-example-item-3-input">Item 3</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="with-disabled-item-example-item-3">
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-disabled-item-example-item-3-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-disabled-item-example-item-3-0-input" name="with-disabled-item" type="radio" value="subitem-1">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-disabled-item-example-item-3-0-input">Subitem 1</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-disabled-item-example-item-3-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-disabled-item-example-item-3-1-input" name="with-disabled-item" type="radio" value="subitem-2">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-disabled-item-example-item-3-1-input">Subitem 2</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-disabled-item-example-item-3-2" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-disabled-item-example-item-3-2-input" name="with-disabled-item" type="radio" value="subitem-3">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-disabled-item-example-item-3-2-input">Subitem 3</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
</ul>
</li>
</ul>
</fieldset>
<!-- /fieldset -->
</div>
<!-- /tree -->
Con item activo #
Mostrar códigodel ejemplo: Con item activo
Contenido
Nunjucks macro
{% from "components/tree/_macro.tree.njk" import componentTree %}
{{ componentTree({
"name": "with-active-item",
"classes": "mt-base",
"fieldset": {
"legend": {
"text": "Selecciona organismo"
}
},
"hint": {
"text": "Selecciona el organismo al que perteneces."
},
"idPrefix": "with-active-item",
"items": [
{
"text": "Item 1",
"id": "with-active-item-example-item-1",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1"
},
{
"text": "Subitem 2",
"value": "subitem-2"
},
{
"text": "Subitem 3",
"value": "subitem-3"
}
],
"attributes": {
"aria-labelledby": "with-active-item-example-item-1"
}
}
},
{
"text": "Item 2",
"id": "with-active-item-example-item-2",
"active": true,
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1"
},
{
"text": "Subitem 2",
"value": "subitem-2"
},
{
"text": "Subitem 3",
"value": "subitem-3"
}
],
"attributes": {
"aria-labelledby": "with-active-item-example-item-2"
}
}
},
{
"text": "Item 3",
"id": "with-active-item-example-item-3",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1"
},
{
"text": "Subitem 2",
"value": "subitem-2"
},
{
"text": "Subitem 3",
"value": "subitem-3"
}
],
"attributes": {
"aria-labelledby": "with-active-item-example-item-3"
}
}
}
]
}) }}
HTML
<!-- tree -->
<div class="c-form-group">
<!-- fieldset -->
<fieldset aria-describedby="with-active-item-hint">
<legend class="font-bold">
Selecciona organismo
</legend>
<!-- hint -->
<p id="with-active-item-hint" class="block text-neutral-dark">Selecciona el organismo al que perteneces.</p>
<!-- /hint -->
<ul class="c-tree mt-base" id="with-active-item" role="tree" data-module="c-tree">
<li id="with-active-item-example-item-1" class="c-tree__item ml-4 focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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-active-item-example-item-1-input" name="with-active-item" type="radio" value="">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="with-active-item-example-item-1-input">Item 1</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="with-active-item-example-item-1">
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-active-item-example-item-1-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-active-item-example-item-1-0-input" name="with-active-item" type="radio" value="subitem-1">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-active-item-example-item-1-0-input">Subitem 1</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-active-item-example-item-1-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-active-item-example-item-1-1-input" name="with-active-item" type="radio" value="subitem-2">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-active-item-example-item-1-1-input">Subitem 2</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-active-item-example-item-1-2" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-active-item-example-item-1-2-input" name="with-active-item" type="radio" value="subitem-3">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-active-item-example-item-1-2-input">Subitem 3</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
</ul>
</li>
<li id="with-active-item-example-item-2" class="c-tree__item ml-4 focus:outline-none font-bold" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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-active-item-example-item-2-input" name="with-active-item" type="radio" value="">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="with-active-item-example-item-2-input">Item 2</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="with-active-item-example-item-2">
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-active-item-example-item-2-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-active-item-example-item-2-0-input" name="with-active-item" type="radio" value="subitem-1">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-active-item-example-item-2-0-input">Subitem 1</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-active-item-example-item-2-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-active-item-example-item-2-1-input" name="with-active-item" type="radio" value="subitem-2">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-active-item-example-item-2-1-input">Subitem 2</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-active-item-example-item-2-2" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-active-item-example-item-2-2-input" name="with-active-item" type="radio" value="subitem-3">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-active-item-example-item-2-2-input">Subitem 3</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
</ul>
</li>
<li id="with-active-item-example-item-3" class="c-tree__item ml-4 focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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-active-item-example-item-3-input" name="with-active-item" type="radio" value="">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="with-active-item-example-item-3-input">Item 3</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="with-active-item-example-item-3">
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-active-item-example-item-3-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-active-item-example-item-3-0-input" name="with-active-item" type="radio" value="subitem-1">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-active-item-example-item-3-0-input">Subitem 1</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-active-item-example-item-3-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-active-item-example-item-3-1-input" name="with-active-item" type="radio" value="subitem-2">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-active-item-example-item-3-1-input">Subitem 2</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-active-item-example-item-3-2" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-active-item-example-item-3-2-input" name="with-active-item" type="radio" value="subitem-3">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-active-item-example-item-3-2-input">Subitem 3</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
</ul>
</li>
</ul>
</fieldset>
<!-- /fieldset -->
</div>
<!-- /tree -->
Con pistas en items #
Mostrar códigodel ejemplo: Con pistas en items
Contenido
Nunjucks macro
{% from "components/tree/_macro.tree.njk" import componentTree %}
{{ componentTree({
"name": "with-hints-on-items",
"classes": "mt-base",
"fieldset": {
"legend": {
"text": "Selecciona organismo"
}
},
"idPrefix": "with-hints-on-items",
"items": [
{
"text": "Item 1",
"hint": {
"text": "Pista en item"
},
"id": "with-hints-on-items-example-item-1",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1",
"hint": {
"text": "Pista en item"
}
},
{
"text": "Subitem 2",
"value": "subitem-2",
"hint": {
"text": "Pista en item"
}
},
{
"text": "Subitem 3",
"value": "subitem-3",
"hint": {
"text": "Pista en item"
}
}
],
"attributes": {
"aria-labelledby": "with-hints-on-items-example-item-1"
}
}
},
{
"text": "Item 2",
"hint": {
"text": "Pista en item"
},
"id": "with-hints-on-items-example-item-2",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1",
"hint": {
"text": "Pista en item"
}
},
{
"text": "Subitem 2",
"value": "subitem-2",
"hint": {
"text": "Pista en item"
}
},
{
"text": "Subitem 3",
"value": "subitem-3",
"hint": {
"text": "Pista en item"
}
}
],
"attributes": {
"aria-labelledby": "with-hints-on-items-example-item-2"
}
}
},
{
"text": "Item 3",
"id": "with-hints-on-items-example-item-3",
"hint": {
"text": "Pista en item"
},
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1",
"hint": {
"text": "Pista en item"
}
},
{
"text": "Subitem 2",
"value": "subitem-2",
"hint": {
"text": "Pista en item"
}
},
{
"text": "Subitem 3",
"value": "subitem-3",
"hint": {
"text": "Pista en item"
}
}
],
"attributes": {
"aria-labelledby": "with-hints-on-items-example-item-3"
}
}
}
]
}) }}
HTML
<!-- tree -->
<div class="c-form-group">
<!-- fieldset -->
<fieldset>
<legend class="font-bold">
Selecciona organismo
</legend>
<ul class="c-tree mt-base" id="with-hints-on-items" role="tree" data-module="c-tree">
<li id="with-hints-on-items-example-item-1" class="c-tree__item ml-4 focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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-hints-on-items-example-item-1-input" name="with-hints-on-items" type="radio" value="" aria-describedby="with-hints-on-items-example-item-1-item-hint">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="with-hints-on-items-example-item-1-input">Item 1</label>
<!-- /label -->
<!-- hint -->
<p id="with-hints-on-items-example-item-1-item-hint" class="block text-neutral-dark">Pista en item</p>
<!-- /hint -->
</div>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="with-hints-on-items-example-item-1">
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-hints-on-items-example-item-1-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-hints-on-items-example-item-1-0-input" name="with-hints-on-items" type="radio" value="subitem-1" aria-describedby="sub-with-hints-on-items-example-item-1-0-item-hint">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-hints-on-items-example-item-1-0-input">Subitem 1</label>
<!-- /label -->
<!-- hint -->
<p id="sub-with-hints-on-items-example-item-1-0-item-hint" class="block text-neutral-dark">Pista en item</p>
<!-- /hint -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-hints-on-items-example-item-1-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-hints-on-items-example-item-1-1-input" name="with-hints-on-items" type="radio" value="subitem-2" aria-describedby="sub-with-hints-on-items-example-item-1-1-item-hint">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-hints-on-items-example-item-1-1-input">Subitem 2</label>
<!-- /label -->
<!-- hint -->
<p id="sub-with-hints-on-items-example-item-1-1-item-hint" class="block text-neutral-dark">Pista en item</p>
<!-- /hint -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-hints-on-items-example-item-1-2" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-hints-on-items-example-item-1-2-input" name="with-hints-on-items" type="radio" value="subitem-3" aria-describedby="sub-with-hints-on-items-example-item-1-2-item-hint">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-hints-on-items-example-item-1-2-input">Subitem 3</label>
<!-- /label -->
<!-- hint -->
<p id="sub-with-hints-on-items-example-item-1-2-item-hint" class="block text-neutral-dark">Pista en item</p>
<!-- /hint -->
</div>
</div>
</div>
</div>
</li>
</ul>
</li>
<li id="with-hints-on-items-example-item-2" class="c-tree__item ml-4 focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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-hints-on-items-example-item-2-input" name="with-hints-on-items" type="radio" value="" aria-describedby="with-hints-on-items-example-item-2-item-hint">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="with-hints-on-items-example-item-2-input">Item 2</label>
<!-- /label -->
<!-- hint -->
<p id="with-hints-on-items-example-item-2-item-hint" class="block text-neutral-dark">Pista en item</p>
<!-- /hint -->
</div>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="with-hints-on-items-example-item-2">
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-hints-on-items-example-item-2-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-hints-on-items-example-item-2-0-input" name="with-hints-on-items" type="radio" value="subitem-1" aria-describedby="sub-with-hints-on-items-example-item-2-0-item-hint">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-hints-on-items-example-item-2-0-input">Subitem 1</label>
<!-- /label -->
<!-- hint -->
<p id="sub-with-hints-on-items-example-item-2-0-item-hint" class="block text-neutral-dark">Pista en item</p>
<!-- /hint -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-hints-on-items-example-item-2-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-hints-on-items-example-item-2-1-input" name="with-hints-on-items" type="radio" value="subitem-2" aria-describedby="sub-with-hints-on-items-example-item-2-1-item-hint">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-hints-on-items-example-item-2-1-input">Subitem 2</label>
<!-- /label -->
<!-- hint -->
<p id="sub-with-hints-on-items-example-item-2-1-item-hint" class="block text-neutral-dark">Pista en item</p>
<!-- /hint -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-hints-on-items-example-item-2-2" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-hints-on-items-example-item-2-2-input" name="with-hints-on-items" type="radio" value="subitem-3" aria-describedby="sub-with-hints-on-items-example-item-2-2-item-hint">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-hints-on-items-example-item-2-2-input">Subitem 3</label>
<!-- /label -->
<!-- hint -->
<p id="sub-with-hints-on-items-example-item-2-2-item-hint" class="block text-neutral-dark">Pista en item</p>
<!-- /hint -->
</div>
</div>
</div>
</div>
</li>
</ul>
</li>
<li id="with-hints-on-items-example-item-3" class="c-tree__item ml-4 focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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-hints-on-items-example-item-3-input" name="with-hints-on-items" type="radio" value="" aria-describedby="with-hints-on-items-example-item-3-item-hint">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="with-hints-on-items-example-item-3-input">Item 3</label>
<!-- /label -->
<!-- hint -->
<p id="with-hints-on-items-example-item-3-item-hint" class="block text-neutral-dark">Pista en item</p>
<!-- /hint -->
</div>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="with-hints-on-items-example-item-3">
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-hints-on-items-example-item-3-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-hints-on-items-example-item-3-0-input" name="with-hints-on-items" type="radio" value="subitem-1" aria-describedby="sub-with-hints-on-items-example-item-3-0-item-hint">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-hints-on-items-example-item-3-0-input">Subitem 1</label>
<!-- /label -->
<!-- hint -->
<p id="sub-with-hints-on-items-example-item-3-0-item-hint" class="block text-neutral-dark">Pista en item</p>
<!-- /hint -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-hints-on-items-example-item-3-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-hints-on-items-example-item-3-1-input" name="with-hints-on-items" type="radio" value="subitem-2" aria-describedby="sub-with-hints-on-items-example-item-3-1-item-hint">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-hints-on-items-example-item-3-1-input">Subitem 2</label>
<!-- /label -->
<!-- hint -->
<p id="sub-with-hints-on-items-example-item-3-1-item-hint" class="block text-neutral-dark">Pista en item</p>
<!-- /hint -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-hints-on-items-example-item-3-2" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-hints-on-items-example-item-3-2-input" name="with-hints-on-items" type="radio" value="subitem-3" aria-describedby="sub-with-hints-on-items-example-item-3-2-item-hint">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-hints-on-items-example-item-3-2-input">Subitem 3</label>
<!-- /label -->
<!-- hint -->
<p id="sub-with-hints-on-items-example-item-3-2-item-hint" class="block text-neutral-dark">Pista en item</p>
<!-- /hint -->
</div>
</div>
</div>
</div>
</li>
</ul>
</li>
</ul>
</fieldset>
<!-- /fieldset -->
</div>
<!-- /tree -->
Con un texto de item muy largo #
Mostrar códigodel ejemplo: Con un texto de item muy largo
Contenido
Nunjucks macro
{% from "components/tree/_macro.tree.njk" import componentTree %}
{{ componentTree({
"name": "with-very-long-option-text",
"classes": "mt-base",
"fieldset": {
"legend": {
"text": "Selecciona organismo"
}
},
"hint": {
"text": "Selecciona el organismo al que perteneces."
},
"idPrefix": "with-very-long-option-text",
"items": [
{
"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.",
"id": "with-very-long-option-text-example-item-1",
"sub": {
"items": [
{
"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": "subitem-1"
},
{
"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": "subitem-2"
},
{
"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.",
"value": "subitem-3"
}
],
"attributes": {
"aria-labelledby": "with-very-long-option-text-example-item-1"
}
}
},
{
"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.",
"id": "with-very-long-option-text-example-item-2",
"sub": {
"items": [
{
"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": "subitem-1"
},
{
"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": "subitem-2"
},
{
"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.",
"value": "subitem-3"
}
],
"attributes": {
"aria-labelledby": "with-very-long-option-text-example-item-2"
}
}
},
{
"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.",
"id": "with-very-long-option-text-example-item-3",
"sub": {
"items": [
{
"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": "subitem-1"
},
{
"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": "subitem-2"
},
{
"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.",
"value": "subitem-3"
}
],
"attributes": {
"aria-labelledby": "with-very-long-option-text-example-item-3"
}
}
}
]
}) }}
HTML
<!-- tree -->
<div class="c-form-group">
<!-- fieldset -->
<fieldset aria-describedby="with-very-long-option-text-hint">
<legend class="font-bold">
Selecciona organismo
</legend>
<!-- hint -->
<p id="with-very-long-option-text-hint" class="block text-neutral-dark">Selecciona el organismo al que perteneces.</p>
<!-- /hint -->
<ul class="c-tree mt-base" id="with-very-long-option-text" role="tree" data-module="c-tree">
<li id="with-very-long-option-text-example-item-1" class="c-tree__item ml-4 focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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-very-long-option-text-example-item-1-input" name="with-very-long-option-text" type="radio" value="">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="with-very-long-option-text-example-item-1-input">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>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="with-very-long-option-text-example-item-1">
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-very-long-option-text-example-item-1-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-very-long-option-text-example-item-1-0-input" name="with-very-long-option-text" type="radio" value="subitem-1">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-very-long-option-text-example-item-1-0-input">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>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-very-long-option-text-example-item-1-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-very-long-option-text-example-item-1-1-input" name="with-very-long-option-text" type="radio" value="subitem-2">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-very-long-option-text-example-item-1-1-input">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>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-very-long-option-text-example-item-1-2" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-very-long-option-text-example-item-1-2-input" name="with-very-long-option-text" type="radio" value="subitem-3">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-very-long-option-text-example-item-1-2-input">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>
</li>
</ul>
</li>
<li id="with-very-long-option-text-example-item-2" class="c-tree__item ml-4 focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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-very-long-option-text-example-item-2-input" name="with-very-long-option-text" type="radio" value="">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="with-very-long-option-text-example-item-2-input">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>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="with-very-long-option-text-example-item-2">
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-very-long-option-text-example-item-2-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-very-long-option-text-example-item-2-0-input" name="with-very-long-option-text" type="radio" value="subitem-1">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-very-long-option-text-example-item-2-0-input">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>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-very-long-option-text-example-item-2-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-very-long-option-text-example-item-2-1-input" name="with-very-long-option-text" type="radio" value="subitem-2">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-very-long-option-text-example-item-2-1-input">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>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-very-long-option-text-example-item-2-2" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-very-long-option-text-example-item-2-2-input" name="with-very-long-option-text" type="radio" value="subitem-3">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-very-long-option-text-example-item-2-2-input">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>
</li>
</ul>
</li>
<li id="with-very-long-option-text-example-item-3" class="c-tree__item ml-4 focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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-very-long-option-text-example-item-3-input" name="with-very-long-option-text" type="radio" value="">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="with-very-long-option-text-example-item-3-input">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>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="with-very-long-option-text-example-item-3">
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-very-long-option-text-example-item-3-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-very-long-option-text-example-item-3-0-input" name="with-very-long-option-text" type="radio" value="subitem-1">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-very-long-option-text-example-item-3-0-input">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>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-very-long-option-text-example-item-3-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-very-long-option-text-example-item-3-1-input" name="with-very-long-option-text" type="radio" value="subitem-2">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-very-long-option-text-example-item-3-1-input">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>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-very-long-option-text-example-item-3-2" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-very-long-option-text-example-item-3-2-input" name="with-very-long-option-text" type="radio" value="subitem-3">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-very-long-option-text-example-item-3-2-input">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>
</li>
</ul>
</li>
</ul>
</fieldset>
<!-- /fieldset -->
</div>
<!-- /tree -->
Con un legend como encabezado #
Mostrar códigodel ejemplo: Con un legend como encabezado
Contenido
Nunjucks macro
{% from "components/tree/_macro.tree.njk" import componentTree %}
{{ componentTree({
"name": "with-legend-as-page-heading",
"fieldset": {
"legend": {
"text": "Selecciona organismo",
"classes": "c-h2",
"isPageHeading": true
},
"headingLevel": 2
},
"idPrefix": "with-legend-as-page-heading",
"items": [
{
"text": "Item 1",
"id": "with-legend-as-page-heading-example-item-1",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1"
},
{
"text": "Subitem 2",
"value": "subitem-2"
},
{
"text": "Subitem 3",
"value": "subitem-3"
}
],
"attributes": {
"aria-labelledby": "with-legend-as-page-heading-example-item-1"
}
}
},
{
"text": "Item 2",
"id": "with-legend-as-page-heading-example-item-2",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1"
},
{
"text": "Subitem 2",
"value": "subitem-2"
},
{
"text": "Subitem 3",
"value": "subitem-3"
}
],
"attributes": {
"aria-labelledby": "with-legend-as-page-heading-example-item-2"
}
}
},
{
"text": "Item 3",
"id": "with-legend-as-page-heading-example-item-3",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1"
},
{
"text": "Subitem 2",
"value": "subitem-2"
},
{
"text": "Subitem 3",
"value": "subitem-3"
}
],
"attributes": {
"aria-labelledby": "with-legend-as-page-heading-example-item-3"
}
}
}
]
}) }}
HTML
<!-- tree -->
<div class="c-form-group">
<!-- fieldset -->
<fieldset>
<legend class="c-h2">
<h2>
Selecciona organismo
</h2>
</legend>
<ul class="c-tree" id="with-legend-as-page-heading" role="tree" data-module="c-tree">
<li id="with-legend-as-page-heading-example-item-1" class="c-tree__item ml-4 focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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-legend-as-page-heading-example-item-1-input" name="with-legend-as-page-heading" type="radio" value="">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="with-legend-as-page-heading-example-item-1-input">Item 1</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="with-legend-as-page-heading-example-item-1">
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-legend-as-page-heading-example-item-1-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-legend-as-page-heading-example-item-1-0-input" name="with-legend-as-page-heading" type="radio" value="subitem-1">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-legend-as-page-heading-example-item-1-0-input">Subitem 1</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-legend-as-page-heading-example-item-1-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-legend-as-page-heading-example-item-1-1-input" name="with-legend-as-page-heading" type="radio" value="subitem-2">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-legend-as-page-heading-example-item-1-1-input">Subitem 2</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-legend-as-page-heading-example-item-1-2" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-legend-as-page-heading-example-item-1-2-input" name="with-legend-as-page-heading" type="radio" value="subitem-3">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-legend-as-page-heading-example-item-1-2-input">Subitem 3</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
</ul>
</li>
<li id="with-legend-as-page-heading-example-item-2" class="c-tree__item ml-4 focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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-legend-as-page-heading-example-item-2-input" name="with-legend-as-page-heading" type="radio" value="">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="with-legend-as-page-heading-example-item-2-input">Item 2</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="with-legend-as-page-heading-example-item-2">
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-legend-as-page-heading-example-item-2-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-legend-as-page-heading-example-item-2-0-input" name="with-legend-as-page-heading" type="radio" value="subitem-1">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-legend-as-page-heading-example-item-2-0-input">Subitem 1</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-legend-as-page-heading-example-item-2-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-legend-as-page-heading-example-item-2-1-input" name="with-legend-as-page-heading" type="radio" value="subitem-2">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-legend-as-page-heading-example-item-2-1-input">Subitem 2</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-legend-as-page-heading-example-item-2-2" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-legend-as-page-heading-example-item-2-2-input" name="with-legend-as-page-heading" type="radio" value="subitem-3">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-legend-as-page-heading-example-item-2-2-input">Subitem 3</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
</ul>
</li>
<li id="with-legend-as-page-heading-example-item-3" class="c-tree__item ml-4 focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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-legend-as-page-heading-example-item-3-input" name="with-legend-as-page-heading" type="radio" value="">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="with-legend-as-page-heading-example-item-3-input">Item 3</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="with-legend-as-page-heading-example-item-3">
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-legend-as-page-heading-example-item-3-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-legend-as-page-heading-example-item-3-0-input" name="with-legend-as-page-heading" type="radio" value="subitem-1">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-legend-as-page-heading-example-item-3-0-input">Subitem 1</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-legend-as-page-heading-example-item-3-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-legend-as-page-heading-example-item-3-1-input" name="with-legend-as-page-heading" type="radio" value="subitem-2">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-legend-as-page-heading-example-item-3-1-input">Subitem 2</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-with-legend-as-page-heading-example-item-3-2" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-with-legend-as-page-heading-example-item-3-2-input" name="with-legend-as-page-heading" type="radio" value="subitem-3">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-with-legend-as-page-heading-example-item-3-2-input">Subitem 3</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
</ul>
</li>
</ul>
</fieldset>
<!-- /fieldset -->
</div>
<!-- /tree -->
Sin fieldset #
Mostrar códigodel ejemplo: Sin fieldset
Contenido
Nunjucks macro
{% from "components/tree/_macro.tree.njk" import componentTree %}
{{ componentTree({
"name": "without-fieldset",
"idPrefix": "without-fieldset",
"items": [
{
"text": "Item 1",
"id": "without-fieldset-example-item-1",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1"
},
{
"text": "Subitem 2",
"value": "subitem-2"
},
{
"text": "Subitem 3",
"value": "subitem-3"
}
],
"attributes": {
"aria-labelledby": "without-fieldset-example-item-1"
}
}
},
{
"text": "Item 2",
"id": "without-fieldset-example-item-2",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1"
},
{
"text": "Subitem 2",
"value": "subitem-2"
},
{
"text": "Subitem 3",
"value": "subitem-3"
}
],
"attributes": {
"aria-labelledby": "without-fieldset-example-item-2"
}
}
},
{
"text": "Item 3",
"id": "without-fieldset-example-item-3",
"sub": {
"items": [
{
"text": "Subitem 1",
"value": "subitem-1"
},
{
"text": "Subitem 2",
"value": "subitem-2"
},
{
"text": "Subitem 3",
"value": "subitem-3"
}
],
"attributes": {
"aria-labelledby": "without-fieldset-example-item-3"
}
}
}
]
}) }}
HTML
<!-- tree -->
<div class="c-form-group">
<ul class="c-tree" id="without-fieldset" role="tree" data-module="c-tree">
<li id="without-fieldset-example-item-1" class="c-tree__item ml-4 focus:outline-none" role="treeitem" data-module="c-tree__item" aria-expanded="false">
<div class="w-full h-full">
<div class="w-full flex items-center relative focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black text-left">
<span class="absolute top-3 -left-4 flex items-center w-4 h-2.5 text-primary-base font-bold after:content-[''] after:absolute after:-left-2 after:p-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__minus">
<path fill="currentColor" d="M9.286 5.714H.714a.714.714 0 010-1.428h8.572a.714.714 0 010 1.428z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true" class="c-tree__plus">
<path fill="currentColor" d="M9.286 4.286H5.893a.179.179 0 01-.179-.179V.714a.714.714 0 00-1.428 0v3.393a.179.179 0 01-.179.179H.714a.714.714 0 000 1.428h3.393a.179.179 0 01.179.179v3.393a.714.714 0 001.428 0V5.893a.179.179 0 01.179-.179h3.393a.714.714 0 000-1.428z" />
</svg>
</span>
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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-example-item-1-input" name="without-fieldset" type="radio" value="">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="without-fieldset-example-item-1-input">Item 1</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</div>
<ul role="group" class='c-tree__itemgroup' aria-labelledby="without-fieldset-example-item-1">
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-without-fieldset-example-item-1-0" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-without-fieldset-example-item-1-0-input" name="without-fieldset" type="radio" value="subitem-1">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class="block block relative -top-xs -left-8 pl-8 py-xs" for="sub-without-fieldset-example-item-1-0-input">Subitem 1</label>
<!-- /label -->
</div>
</div>
</div>
</div>
</li>
<li class="c-tree__item ml-8 origin-top-left focus:outline-none" id="sub-without-fieldset-example-item-1-1" role="treeitem" data-module="c-tree__item">
<div class="block">
<div>
<div class="relative flex items-start py-xs">
<div class="flex items-center mx-sm">
<input class="w-6 h-6 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="sub-without-fieldset-example-item-1-1-input" name="without-fieldset" type="radio" value="subitem-2">
</div>
<div class="flex-1 pt-0.5 leading-5">
<!-- label -->
<label class=