Building Reusable Sitecore Components with Angular JSS
Sitecore + Angular JSS Series — Part 4
2026-10-20
In the previous articles, we explored how Sitecore JSS works with Angular, how the Layout Service delivers page composition, and how GraphQL can be used to retrieve Sitecore data.
The next question naturally becomes:
This is one of the most important aspects of a headless Sitecore implementation.
A component should not simply be an Angular component that displays some HTML. A well-designed Sitecore component should provide a clear contract between:
- Sitecore authors
- Sitecore content structure
- Layout Service
- Angular/JSS
- Frontend design system
The goal is to build a component once and allow it to be reused across multiple pages and scenarios.
1. What Does “Reusable Component” Mean in Sitecore?
Consider a typical website.
You may have:
- Hero banners
- Content cards
- CTA blocks
- Image + text sections
- Promotional banners
- Accordion sections
- Contact information
- Product cards
- Rich text sections
A common mistake is to build every variation as a completely separate component.
For example:
HomeHero
ProductHero
CampaignHero
ArticleHero
ServiceHeroThis can quickly become difficult to maintain.
Instead, we can create a reusable component:
- Hero
- Title
- Description
- Image
- CTA
- Variant
The same Angular component can then support different Sitecore content and presentation requirements.
Conceptually:
This separation is one of the biggest advantages of a headless architecture.
2. Sitecore Rendering vs Angular Component
One of the most important concepts to understand is that a Sitecore rendering and an Angular component are related, but they are not the same thing.
Think about them as two sides of the same contract.
Sitecore side
Sitecore defines:
- Component definition
- Datasource
- Fields
- Placeholder settings
- Rendering parameters
- Authoring experience
Angular side
Angular defines:
- HTML
- CSS/SCSS
- Component behavior
- Accessibility
- Responsive behavior
- Client-side interactions
The relationship looks like this:
- Rendering Definition
- Datasource Template
- Placeholder Settings
- Rendering Parameters
- componentName
- fields
- params
- placeholders
- HeroComponent
- CardComponent
- CTAComponent
This means the Angular component should be designed around the data contract provided by Sitecore.
3. Start With the Content Model
Before writing Angular code, define what the component actually needs.
Let's take a simple Hero component.
We want:
- Hero
- Title
- Description
- Image
- CTA Text
- CTA Link
A corresponding Sitecore datasource template could contain:
- Hero Template
- Title
- Description
- Image
- CTA Text
- CTA Link
This gives content authors control over the content without requiring developers to modify Angular code.
A good rule is:
For example, avoid storing HTML directly in a field just because Angular needs to render a particular layout.
Instead of:
<div class="hero-title">Welcome</div>store:
Title = Welcomeand allow Angular to control the presentation.
4. Define the Component Contract
Before implementing the component, define its contract.
For example:
Hero Component
Required:
- Title
Optional:
- Description
- Image
- CTA
Supported variants:
- Default
- Dark
- Full WidthThis sounds simple, but it prevents a lot of frontend complexity later.
A useful component contract might look like:
- Hero
- Content
- Title
- Description
- CTA
- Media
- Image
- Presentation
- Variant
- Alignment
- Theme
The content and presentation concerns remain separate.
5. Component Registration in Angular
Once the Sitecore rendering is created, the Angular application needs to know which Angular component should render it.
A typical JSS component mapping looks like:
import { HeroComponent } from './components/hero/hero.component';
export const componentFactory = {
Hero: HeroComponent
};Depending on the JSS version and application setup, this mapping can be registered through the JSS component factory.
The important concept is:
For example:
This mapping is what allows Layout Service data to become an actual Angular component.
6. Creating the Angular Component
A basic Angular JSS component could look like this:
import { Component, Input } from '@angular/core';
@Component({
selector: 'app-hero',
templateUrl: './hero.component.html',
styleUrls: ['./hero.component.scss']
})
export class HeroComponent {
@Input() rendering: any;
}The rendering object contains the data provided by Sitecore/JSS.
For example:
rendering.fields.Title.valuecould contain the title.
A more structured model is preferable for larger applications.
export interface HeroFields {
Title: any;
Description: any;
Image: any;
CtaText: any;
CtaLink: any;
}Then:
export interface HeroRendering {
fields: HeroFields;
params?: {
variant?: string;
alignment?: string;
};
}And the component:
export class HeroComponent {
@Input() rendering!: HeroRendering;
}This gives the component a much clearer contract.
7. Rendering Sitecore Fields
JSS provides field rendering helpers so that Sitecore fields can be rendered correctly.
For example:
<h1>
<span *scText="rendering.fields.Title"></span>
</h1>For an image:
<img
*scImage="rendering.fields.Image"
alt=""
/>For a link:
<a *scLink="rendering.fields.CtaLink">
<span *scText="rendering.fields.CtaText"></span>
</a>The exact helper syntax can vary depending on the JSS version being used, so the implementation should always follow the version of @sitecore-jss/sitecore-jss-angular used by the project.
The important advantage is that JSS field helpers preserve Sitecore-aware rendering behavior instead of treating everything as plain strings.
8. Complete Hero Example
Let's combine these concepts.
hero.component.ts
import { Component, Input } from '@angular/core';
@Component({
selector: 'app-hero',
templateUrl: './hero.component.html',
styleUrls: ['./hero.component.scss']
})
export class HeroComponent {
@Input() rendering: any;
get variant(): string {
return this.rendering?.params?.variant || 'default';
}
}hero.component.html
<section
class="hero"
[ngClass]="'hero--' + variant"
>
<div class="hero__content">
<h1 *scText="rendering.fields.Title"></h1>
<div
class="hero__description"
*scRichText="rendering.fields.Description">
</div>
<a
class="hero__cta"
*scLink="rendering.fields.CtaLink"
>
<span *scText="rendering.fields.CtaText"></span>
</a>
</div>
<div class="hero__media">
<img
*scImage="rendering.fields.Image"
alt=""
/>
</div>
</section>The Angular component doesn't need to know which page contains it.
It only knows about its contract.
That is what makes it reusable.
9. Datasource-Driven Components
One of the most powerful patterns in Sitecore is the datasource-driven component.
Instead of storing component content directly on the page item, the component can reference a separate datasource item.
For example:
- Home Page
- Hero Rendering“Datasource → Home Hero”
- Content Card Rendering“Datasource → Product Card 1”
- Content Card Rendering“Datasource → Product Card 2”
This creates a clean separation:
This becomes especially useful when the same content needs to be reused.
For example:
- Global Promotion
- Home Page
- Product Page
- Campaign Page
Instead of duplicating the content, multiple renderings can reference the same datasource item where appropriate.
10. Reusable Content Card
Let's create another example.
A Content Card might contain:
- Title
- Description
- Image
- Link
The Angular component:
@Component({
selector: 'app-content-card',
templateUrl: './content-card.component.html'
})
export class ContentCardComponent {
@Input() rendering: any;
}Template:
<article class="content-card">
<div class="content-card__image">
<img
*scImage="rendering.fields.Image"
alt=""
/>
</div>
<div class="content-card__content">
<h2>
<span *scText="rendering.fields.Title"></span>
</h2>
<div
*scRichText="rendering.fields.Description">
</div>
<a
*scLink="rendering.fields.Link"
class="content-card__link"
>
Read more
</a>
</div>
</article>Now the same component can be used for:
- Product cards
- Service cards
- Article cards
- Campaign cards
- Information cards
without creating five separate Angular components.
11. Rendering Parameters
Sometimes the content should remain the same but the presentation needs to change.
For example:
- Hero
- Default
- Dark
- Full Width
- Centered
This is where rendering parameters can be useful.
Conceptually:
- Datasource
- Title
- Description
- Image
- Rendering Parameters
- Variant = Dark
- Alignment = Center
- Width = Full
Angular can then consume those parameters.
get variant(): string {
return this.rendering?.params?.variant || 'default';
}And:
<section
class="hero"
[ngClass]="{
'hero--dark': variant === 'dark',
'hero--center': rendering?.params?.alignment === 'center',
'hero--full-width': rendering?.params?.width === 'full'
}"
>This is generally cleaner than duplicating the entire component.
12. Component Variants
A reusable component doesn't mean every variation should be handled with hundreds of if statements.
Avoid:
if (type === 'A') {
// 100 lines
}
if (type === 'B') {
// 100 lines
}
if (type === 'C') {
// 100 lines
}Instead, keep variants intentionally small.
For example:
<section
class="hero"
[class.hero--dark]="variant === 'dark'"
[class.hero--centered]="variant === 'centered'"
>The SCSS handles the visual differences:
.hero {
display: flex;
&--dark {
// dark variant
}
&--centered {
// centered variant
}
}If the behavior becomes fundamentally different, it may be better to create a separate component rather than forcing everything into one.
A useful rule:
13. Placeholder Settings
Reusable components become even more powerful when they can contain other components.
Consider a Promo Section:
- Promo Section
- Title
- Description
- Content Placeholder
- Card
- Card
- CTA
The Sitecore placeholder settings determine which components can be inserted into that placeholder.
Conceptually:
- PromoSection
- promo-content
- ContentCard
- ContentCard
- CTA
Angular then renders the placeholder dynamically.
For example:
<section class="promo">
<h2 *scText="rendering.fields.Title"></h2>
<div class="promo__content">
<sc-placeholder
name="promo-content"
[rendering]="rendering">
</sc-placeholder>
</div>
</section>This is where the combination of Sitecore authoring and Angular rendering becomes particularly powerful.
Authors control the composition.
Angular controls the implementation.
14. Component Composition
A mature JSS application should allow components to be composed rather than creating large monolithic components.
Avoid:
- MegaPageComponent
- Hero
- Cards
- Accordion
- Form
- Map
- Footer
- Everything else
Instead:
- Page
- Hero
- Content Section
- Card
- Card
- CTA
- Accordion
- Contact Section
- Map
- Contact Details
This makes components:
- Easier to test
- Easier to maintain
- Easier to reuse
- Easier to style
- Easier to optimize
15. Responsive Design
A Sitecore component should not rely on the page to make it responsive.
The component should have its own responsive behavior.
For example:
.hero {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 2rem;
@media (max-width: 768px) {
grid-template-columns: 1fr;
}
}This means the component remains reusable regardless of where it is placed.
For a card:
.content-card {
display: flex;
flex-direction: column;
&__image {
width: 100%;
}
}Avoid hardcoding page-specific dimensions unless the component contract explicitly requires them.
16. Accessibility Should Be Part of the Component
Reusable components should include accessibility from the beginning.
For example, don't create:
<div (click)="open()">
Open
</div>when the element is actually a button.
Prefer:
<button
type="button"
(click)="open()"
>
Open
</button>For images, make sure the Sitecore content model supports appropriate alternative text.
For links:
<a
*scLink="rendering.fields.CtaLink"
class="hero__cta"
>
<span *scText="rendering.fields.CtaText"></span>
</a>For interactive components, consider:
- Keyboard navigation
- Focus states
- ARIA attributes where necessary
- Semantic HTML
- Screen reader behavior
- RTL behavior
Accessibility should not be treated as a final QA activity.
It should be part of the component contract.
17. RTL and Multilingual Components
For multilingual Sitecore applications, component design should avoid assumptions about text direction.
For example:
<section
class="hero"
[dir]="currentLanguage?.direction"
>The component should support:
- LTR
- English
- French
- German
- RTL
- Arabic
Avoid hardcoding:
margin-left: 20px;when the intention is actually “space before the content.”
Prefer logical properties:
margin-inline-start: 20px;
padding-inline-end: 16px;This allows the browser to handle direction correctly.
Similarly:
text-align: start;is often preferable to:
text-align: left;for reusable multilingual components.
18. Sitecore Authoring Experience
A reusable component is successful only if content authors can actually use it.
Developers should think about:
What fields are required?
| Field | Requirement |
|---|---|
| Title | Required |
| Image | Optional |
| Description | Optional |
| CTA | Optional |
What components can be inserted?
- Hero
- No child components
- Content Section
- Card
- CTA
- Image
- Rich Text
What should authors control?
Use rendering parameters for presentation choices such as:
- Theme
- Alignment
- Width
- Style
Avoid exposing technical implementation details to authors.
For example, don't expose:
CSS class = hero-v3-dark-finalInstead expose:
Theme = DarkThe Sitecore author should work with business concepts, not implementation details.
19. Avoid Over-Generic Components
There is a common trap when trying to make components reusable.
Developers sometimes create a component like:
UniversalContentComponentwith:
- 40 fields
- 20 variants
- 15 configuration options
- 10 conditional layouts
This component might technically support everything.
But it becomes difficult to understand and maintain.
Instead, prefer:
- Hero
- ContentCard
- PromoBanner
- CTA
- Accordion
with clear responsibilities.
A good reusable component should be:
20. Component Folder Structure
A clean Angular project structure could look like:
- src
- app
- components
- hero
- hero.component.ts
- hero.component.html
- hero.component.scss
- hero.model.ts
- content-card
- content-card.component.ts
- content-card.component.html
- content-card.component.scss
- content-card.model.ts
- cta
- cta.component.ts
- cta.component.html
- cta.component.scss
- services
- sitecore
- shared
- models
- utilities
For larger projects, you can also organize components by feature or design-system category.
21. Recommended Component Architecture
A useful architecture is:
- Templates
- Datasources
- Renderings
- Placeholder Settings
- fields
- params
- placeholders
- Component Factory
- HeroComponent
- HTML/SCSS
- CardComponent
- HTML/SCSS
- CtaComponent
- HTML/SCSS
This architecture keeps responsibilities clear.
22. Debugging Reusable Components
When a component does not render correctly, don't immediately start debugging the Angular HTML.
Follow the data flow.
Step 1 — Check Sitecore
Verify:
- Rendering exists
- Datasource exists
- Fields are populated
- Rendering is added to the page
- Placeholder settings are correct
Step 2 — Check Layout Service
Open the browser Network tab.
Find the Layout Service request.
Look for:
{
"componentName": "Hero",
"fields": {
"Title": {},
"Description": {},
"Image": {}
},
"params": {}
}Step 3 — Check Angular Mapping
Verify:
Step 4 — Check Input
Temporarily inspect:
ngOnInit() {
console.log(this.rendering);
}Step 5 — Check the Template
Only after confirming the data is available should you investigate:
- *scText
- *scImage
- *scLink
This approach is much faster than debugging everything at the Angular layer first.
23. Common Mistakes
Mistake 1 — Hardcoding Sitecore content
Avoid:
title = 'Welcome to our website';when the value should come from Sitecore.
Prefer:
rendering.fields.TitleMistake 2 — Creating a component for every small variation
Avoid:
HeroA
HeroB
HeroC
HeroDif they share the same content contract.
Use variants when appropriate.
Mistake 3 — Making one component handle everything
Avoid:
UniversalComponentwith dozens of fields and conditions.
Keep components focused.
Mistake 4 — Ignoring placeholder settings
A technically correct Angular component can still provide a poor Sitecore authoring experience if placeholder settings are incorrect.
Mistake 5 — Mixing content and presentation
Don't use Sitecore fields to store frontend implementation details.
For example:
CSSClass = "hero-v2-special"is usually a poor content model.
Prefer:
Theme = Darkand let Angular translate that into styling.
Mistake 6 — Ignoring accessibility until the end
Reusable components should be accessible by default.
24. Testing Reusable Components
A reusable component should be tested independently.
For example:
- HeroComponent
- renders title
- renders description
- renders image
- renders CTA
- handles missing image
- handles missing CTA
- applies variant
- supports RTL
- supports keyboard navigation
You should also test the component with realistic Sitecore rendering data.
For example:
const mockRendering = {
fields: {
Title: {
value: 'Welcome'
},
Description: {
value: 'Example description'
}
},
params: {
variant: 'dark'
}
};This allows Angular tests to validate the component without requiring a complete Sitecore environment for every test.
25. A Small GitHub POC
For this article, a useful POC would contain three reusable components:
- sitecore-jss-angular-reusable-components
- README.md
- src
- app
- components
- hero
- hero.component.ts
- hero.component.html
- hero.component.scss
- content-card
- content-card.component.ts
- content-card.component.html
- content-card.component.scss
- cta
- cta.component.ts
- cta.component.html
- cta.component.scss
- sitecore
- templates
- renderings
- placeholder-settings
- docs
- architecture.md
The README should explain:
- Sitecore content model
- Rendering configuration
- Datasource configuration
- Angular component mapping
- Layout Service response
- Component rendering
This turns the article from a theoretical explanation into a practical portfolio project.
26. Version Compatibility Note
One important point when creating a public GitHub POC is to clearly document the versions.
For example:
Angular: 11.x
Sitecore JSS: <project-compatible-version>
Node.js: <supported-version>Do not copy the latest Sitecore JSS documentation into an Angular 11 project without checking API/package compatibility.
Sitecore JSS and Angular APIs have evolved over time, so the code in the POC should explicitly state which versions it targets.
This is especially important if your production project is based on Angular 11.
27. From Reusable Components to a Design System
Once you have reusable Sitecore components, you can take the architecture one step further.
For example:
- Button
- Typography
- Card
- Modal
- Accordion
- Form Controls
- Hero
- Product Card
- Promo Banner
- Contact Section
- Content Section
This creates consistency between:
This is particularly valuable for large enterprise websites.
28. The Key Architectural Lesson
The most important lesson is that reusability is not only an Angular concern.
A truly reusable Sitecore component requires coordination between:
If any one of these is poorly designed, the component becomes harder to reuse.
29. Final Architecture
The complete picture looks like this:
30. Conclusion
Building reusable Sitecore components with Angular JSS is more than creating reusable Angular classes.
The real goal is to create a reusable content-to-component contract.
Sitecore controls:
- Content
- Datasources
- Rendering definitions
- Placeholder rules
- Authoring configuration
Angular controls:
- Rendering
- Behavior
- Styling
- Responsiveness
- Accessibility
JSS connects the two.
A good reusable component should be:
- Focused
- Configurable
- Datasource-driven
- Author-friendly
- Responsive
- Accessible
- Multilingual
- Testable
- Easy to maintain
The architectural principle I would keep in mind is:
When the content model, rendering definition, datasource, and Angular implementation are designed together, the result is a system that scales much better than a collection of page-specific components.
What's Next?
In the next article, we will move from component development into one of the areas developers spend a lot of time on in real projects:
We will look at a practical debugging workflow covering:
and investigate common problems such as:
- Component not rendering
- Missing datasource
- Incorrect component mapping
- Empty fields
- Placeholder issues
- Rendering parameter problems
- Layout Service issues
- Client-side Angular errors
- Experience Editor problems
- Environment-specific issues