Text element

For basic text formatting and sizes.

github location npm version

Usage

The vf-text component leverages the design token typography sizes.

This component provides a utility-like functionality and you'll rarely need to directly use this component. When coding a component's Sass, it will typically be better to use the mixins (@include set-type(text-body--6);) than these vf-text classes.

Variants

This text is extra large

Nunjucks syntax

Depending on your environment you'll want to use render or include. As a rule of thumb: server-side use include, precompiled browser use render. If you're using vf-eleventy you should use include.

Using include

You'll need to pass a context object from your code or Yaml file (example), as well as the path to the Nunjucks template. Nunjucks' include is an abstraction of render and provides some additional portability.


{% set context fromYourYamlFile %}
- or -
{% set context = { 
"component-type" : "element",
"text" : "This text is extra large",
"type" : 1,
 }
%}
{% include "../path_to/vf-text/vf-text.njk" %}
                

Using render

This approach is best for bare-bones Nunjucks environments, such as precompiled templates with the Nunjucks slim runtime where include is not be available.


{% render '@vf-text', {
  "component-type" : "element",
  "text" : "This text is extra large",
  "type" : 1,}
%}
                
HTML
 <p class="vf-text-body vf-text-body--1">This text is extra large</p>
              

This text is large

Nunjucks syntax

Depending on your environment you'll want to use render or include. As a rule of thumb: server-side use include, precompiled browser use render. If you're using vf-eleventy you should use include.

Using include

You'll need to pass a context object from your code or Yaml file (example), as well as the path to the Nunjucks template. Nunjucks' include is an abstraction of render and provides some additional portability.


{% set context fromYourYamlFile %}
- or -
{% set context = { 
"component-type" : "element",
"text" : "This text is large",
"type" : 2,
 }
%}
{% include "../path_to/vf-text/vf-text.njk" %}
                

Using render

This approach is best for bare-bones Nunjucks environments, such as precompiled templates with the Nunjucks slim runtime where include is not be available.


{% render '@vf-text', {
  "component-type" : "element",
  "text" : "This text is large",
  "type" : 2,}
%}
                
HTML
 <p class="vf-text-body vf-text-body--2">This text is large</p>
              

This text is regular

Nunjucks syntax

Depending on your environment you'll want to use render or include. As a rule of thumb: server-side use include, precompiled browser use render. If you're using vf-eleventy you should use include.

Using include

You'll need to pass a context object from your code or Yaml file (example), as well as the path to the Nunjucks template. Nunjucks' include is an abstraction of render and provides some additional portability.


{% set context fromYourYamlFile %}
- or -
{% set context = { 
"component-type" : "element",
"text" : "This text is regular",
"type" : 3,
 }
%}
{% include "../path_to/vf-text/vf-text.njk" %}
                

Using render

This approach is best for bare-bones Nunjucks environments, such as precompiled templates with the Nunjucks slim runtime where include is not be available.


{% render '@vf-text', {
  "component-type" : "element",
  "text" : "This text is regular",
  "type" : 3,}
%}
                
HTML
 <p class="vf-text-body vf-text-body--3">This text is regular</p>
              

This text is small

Nunjucks syntax

Depending on your environment you'll want to use render or include. As a rule of thumb: server-side use include, precompiled browser use render. If you're using vf-eleventy you should use include.

Using include

You'll need to pass a context object from your code or Yaml file (example), as well as the path to the Nunjucks template. Nunjucks' include is an abstraction of render and provides some additional portability.


{% set context fromYourYamlFile %}
- or -
{% set context = { 
"component-type" : "element",
"text" : "This text is small",
"type" : 4,
 }
%}
{% include "../path_to/vf-text/vf-text.njk" %}
                

Using render

This approach is best for bare-bones Nunjucks environments, such as precompiled templates with the Nunjucks slim runtime where include is not be available.


{% render '@vf-text', {
  "component-type" : "element",
  "text" : "This text is small",
  "type" : 4,}
%}
                
HTML
 <p class="vf-text-body vf-text-body--4">This text is small</p>
              

This text is extra small

Nunjucks syntax

Depending on your environment you'll want to use render or include. As a rule of thumb: server-side use include, precompiled browser use render. If you're using vf-eleventy you should use include.

Using include

You'll need to pass a context object from your code or Yaml file (example), as well as the path to the Nunjucks template. Nunjucks' include is an abstraction of render and provides some additional portability.


{% set context fromYourYamlFile %}
- or -
{% set context = { 
"component-type" : "element",
"text" : "This text is extra small",
"type" : 5,
 }
%}
{% include "../path_to/vf-text/vf-text.njk" %}
                

Using render

This approach is best for bare-bones Nunjucks environments, such as precompiled templates with the Nunjucks slim runtime where include is not be available.


{% render '@vf-text', {
  "component-type" : "element",
  "text" : "This text is extra small",
  "type" : 5,}
%}
                
HTML
 <p class="vf-text-body vf-text-body--5">This text is extra small</p>
              

Examples

Installation info

This component is distributed with npm. After installing npm, you can install the vf-text with this command.

$ yarn add --dev @visual-framework/vf-text

Sass/CSS

The source files included are written in Sass(scss). You can point your Sass include-path at your node_modules directory and import it like this.

@import "@visual-framework/vf-text/index.scss";

Make sure you import Sass requirements along with the modules. You can use a project boilerplate or the vf-sass-starter

Changelog

Changelog

1.1.0

  • Changes of name of variants to reflect connection to design tokens.
  • https://github.com/visual-framework/vf-core/issues/1661

1.0.1

  • Add notes to README.md

1.0.0

  • Initial stable release

Assets



File system location: components/vf-text

Find an issue on this page? Propose a change or discuss it.