Use a Library to share Component "Library files" between components. The most
typical usage is in conjunction with
namespace, as below:
Libraries use their attributes to configure the Components that they load. That means their attributes are the same as the Component class attributes, except they are "applied" across all child components. This means you can configure any configuration option on Components. However, you typically only want to set namespace, and possibly mode.
- The namespace prefix that goes before the component when registering on
the DOM. This is the most common thing you will set on a Library, since
it allows you to "namespace" or isolate the components that you load and
prevent names from conflicting. For example, you can import two
Libraries, each with a
name="Modal"component, but by giving them separate namespaces, you can distinguish them with something like
lib2-Modal, instead of
x-Modalfor both, which would get confusing.
- Override the default mode of loaded components.
- You can use this to force a Library to have vanishing components
mode="vanish"), or have components that isolate their style (
- default: (none)
- Override the default alias of loaded components
- This allows you to give the components a "nick-name" that you then refer to them as in your Template
aliasis specified while
namespaceleft blank, the components will get an auto-generated and unique namespace based on on the full definition name of the component
- When your templates compile, they will swap the tags for the nick-name, allowing you to have easily remembered local names for imported Library components, but the final component will have a long, unique tag name (and all that will be "baked in" to the final compiled template