Description
Polymorpheus is a tiny, dependency-free library for polymorphic templates in Angular. It is about 1 KB gzipped. Its main tool is one structural directive that lets a component accept different kinds of content for a part of its view. That content can be a primitive such as a string or number, a function that takes a context and returns a primitive, a template that is instantiated with a context, or a component that receives the context through dependency injection. The context is optional, so you only add it when the content needs to adapt to the situation. A typical case is a menu where the caller decides how each item looks, with the item and its focus state as the context. Components can read the context with the POLYMORPHEUS_CONTEXT token or the injectContext helper, and the context object is live, so the view updates when it changes. A polymorpheus directive can add a type to the template context. The README links to a demo you can run locally.…
Highlights
- One structural directive for customizable views
- Content can be text, a function, a template or a component
- Live context object for components
- About 1 KB gzipped with no dependencies
Ratings & Reviews
No ratings yet
Be the first to rate polymorpheus.
People also visit
polymorpheus FAQ
What is Polymorpheus?
A small Angular library for polymorphic templates, which let a component accept different kinds of content through one directive.
What kinds of content does it accept?
Primitives like strings or numbers, functions that take a context, templates instantiated with a context, and components that get the context through dependency injection.
How does a component read the context?
Through the POLYMORPHEUS_CONTEXT token or the injectContext helper. The context is live, so the view updates when it changes.
Does it have dependencies?
No. The README describes it as dependency free and about 1 KB gzipped.
What are the best polymorpheus alternatives?
Popular alternatives to polymorpheus include ngx-layout, ngx-drag-scroll and ngx-bootstrap-icons. See all polymorpheus alternatives


















