The HTML for the demonstration above is rendered using context passed to the component's Thymeleaf template fragment. Learn how to include component templates for Thymeleaf and Ruby in the source and usage section .
Copy the following block to clipboard
<header >
<div class ="grid-container display-flex flex-justify flex-align-center tablet:padding-y-2" >
<div >
<a href ="https://codeforamerica.github.io/uswds/" >
<svg xmlns ="http://www.w3.org/2000/svg" class ="display-block tablet:display-none" role ="img" aria-hidden ="true" style ="width: 101px; height: 82px" >
<use href ="#logo-cfa-stacked" >
</use >
</svg >
<svg xmlns ="http://www.w3.org/2000/svg" class ="display-none tablet:display-block" role ="img" aria-hidden ="true" style ="width: 161px; height: 49px" >
<use href ="#logo-cfa-long" >
</use >
</svg >
<span class ="usa-sr-only" > Code for America</span >
</a >
</div >
<div class ="display-flex" >
<button class ="usa-button cfa-button usa-button--primary flex-1" >
<svg class ="usa-icon display-none mobile-lg:display-inline-block" aria-hidden ="true" focusable ="false" role ="img" >
<use href ="https://codeforamerica.github.io/uswds/assets/img/sprite.svg#chat" > </use >
</svg >
<span > Chat</span >
</button >
<div class ="display-flex flex-align-center" >
<button class ="usa-button cfa-button usa-button--outline cfa-button--sub-label flex-auto margin-0 desktop:display-none" >
<svg class ="usa-icon display-none mobile-lg:display-inline-block" aria-hidden ="true" focusable ="false" role ="img" >
<use href ="https://codeforamerica.github.io/uswds/assets/img/sprite.svg#translate" > </use >
</svg >
<span > Translate <span class ="usa-sr-only" > to </span >
<small class ="cfa-button__sub-label" >
<span lang ="en" > English</span > , <span lang ="es" > Español</span >
</small >
</span >
</button >
<nav aria-label ="Translate" class ="display-none desktop:display-inline-block" >
<a lang ="en" href ="?lang=en" class ="margin-left-1" > English</a >
<a lang ="es" href ="?lang=es" class ="margin-left-1" > Español</a >
</nav >
</div >
</div >
</div >
</header >
Context is the information necessary to configure and render a component template to HTML. It may include plain text strings, HTML, class names, IDs or other HTML attribute values. The context here is defined as JSON but the root attributes are translated to different variable syntaxes for Thymeleaf and Ruby templates. Learn how to pass these variables to each component template in the source and usage section .
Copy the following block to clipboard
{
"alert" : {
"modifier" : "cfa-alert cfa-site-alert usa-alert--info margin-0 border-top-0 border-x-0" ,
"role" : "status" ,
"text" : "This site is for demonstration purposes only."
} ,
"container" : {
"modifier" : "tablet:padding-y-2"
} ,
"home" : {
"href" : "https://codeforamerica.github.io/uswds/"
} ,
"logo" : {
"alt" : {
"modifier" : "usa-sr-only" ,
"text" : "Code for America"
} ,
"default" : {
"href" : "#logo-cfa-stacked" ,
"style" : "width: 101px; height: 82px"
} ,
"tablet" : {
"href" : "#logo-cfa-long" ,
"style" : "width: 161px; height: 49px"
}
} ,
"chat" : "https://codeforamerica.github.io/uswds/assets/img/sprite.svg#chat" ,
"languageSelector" : "https://codeforamerica.github.io/uswds/assets/img/sprite.svg#translate"
}