Skip to main content

Angular Material & CDK Custom Component Builder

Build custom Angular components using CDK primitives — overlay, drag-drop, virtual scrolling, and accessibility patterns.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt
Build a custom multi-select dropdown with search and chips Angular component using Angular CDK. Requirements: searchable options, chip display for selected items, async option loading, group support. Include: 1) Component structure with CDK Overlay, a11y (FocusTrap, LiveAnnouncer), Scrolling primitives, 2) Full keyboard navigation (Tab, Arrow keys, Enter, Escape), 3) ARIA attributes and roles for accessibility (WCAG 2.1 AA), 4) Theming integration with Angular Material theming system, 5) Responsive behavior for mobile (dropdown becomes full-screen), tablet, desktop, 6) Animation using Angular animations API, 7) Form integration with ControlValueAccessor for reactive forms, 8) Content projection with ng-content and ng-template, 9) Unit tests covering keyboard navigation, ARIA, and visual states, 10) Storybook stories for all component variants. Follow Angular Material design patterns for consistency. Include the component, its module/standalone setup, and usage examples.

What this prompt does

This prompt directs the AI to build a custom [component_name] Angular component on top of Angular CDK primitives rather than reinventing low-level behaviour. You describe the [requirements], choose which [cdk_features] to lean on (Overlay, a11y helpers, Scrolling), and set the [wcag_level] and [breakpoints], and it returns a component wired for keyboard navigation, ARIA, theming, animation, and reactive forms. The output also includes content projection slots and the tests and stories that keep the component maintainable.

It works because CDK already solves the hard parts — focus trapping, overlay positioning, live announcements — and the prompt forces the AI to use those instead of hand-rolling buggy equivalents. Naming the [breakpoints] makes responsive behaviour explicit (for example a dropdown that becomes full-screen on mobile), and requiring ControlValueAccessor means the component drops straight into Angular reactive forms with formControlName. The accessibility requirements are baked into the spec at the chosen [wcag_level], not bolted on afterward, so keyboard and ARIA support arrive with the first version rather than as a later retrofit.

When to use it

  • Building a component Angular Material doesn't ship (multi-select with chips, custom pickers)
  • Needing keyboard navigation and ARIA that meet a specific [wcag_level]
  • Wanting a component that integrates with reactive forms via ControlValueAccessor
  • Reusing CDK Overlay or FocusTrap instead of writing positioning and focus logic by hand
  • Standardising responsive behaviour across [breakpoints] for a shared component library
  • Producing Storybook stories and tests alongside the component for a design system

Example output

You get the full component: template and class using the chosen [cdk_features], keyboard handlers for Tab/Arrow/Enter/Escape, ARIA roles and attributes meeting [wcag_level], Angular Material theming hooks, animation via the animations API, ControlValueAccessor wiring for reactive forms, content projection slots using ng-content and ng-template, unit tests covering navigation and ARIA states, and Storybook stories for each variant. Standalone or NgModule setup and usage examples are included so it drops into a real project.

Pro tips

  • Make [requirements] concrete (searchable options, async loading, group support) so the AI scopes the component correctly instead of guessing
  • Only request the [cdk_features] you need; pulling in Overlay, a11y and Scrolling together adds complexity if the component is simple
  • Set [wcag_level] to your real compliance target — 2.1 AA is common — because it changes which ARIA and contrast checks the tests enforce
  • Spell out responsive intent in [breakpoints], like the dropdown going full-screen on mobile, or you'll get desktop-only behaviour
  • Verify the generated ARIA against a real screen reader; automated tests catch attributes but not awkward or confusing announcements
  • Wire the component through ControlValueAccessor early so validation and value changes flow naturally inside reactive form groups
  • If you use standalone components, say so explicitly so the AI skips the NgModule boilerplate and emits the standalone setup instead

Frequently Asked Questions

Which Angular CDK primitives does this prompt build on?
It uses whichever you list in `[cdk_features]`, commonly Overlay for positioning, the a11y package (FocusTrap, LiveAnnouncer) for accessibility, and Scrolling for virtual lists. Naming only the primitives you need keeps the component from carrying unnecessary CDK dependencies.
Does the component integrate with Angular reactive forms?
Yes, it implements ControlValueAccessor so the component works inside reactive form groups like any native control. This lets you bind it with formControlName and have validation and value changes flow through normally.
What WCAG level does it target?
It targets the `[wcag_level]` you specify, with 2.1 AA being the typical choice. That setting drives the ARIA attributes, focus management, and contrast checks the generated tests enforce, so set it to your actual compliance requirement.
Does it generate tests and Storybook stories too?
Yes, it produces unit tests covering keyboard navigation, ARIA, and visual states, plus Storybook stories for each variant. Treat the accessibility tests as a baseline and still validate the component manually with a screen reader.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in Vue.js & Angular Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

AI assistant · trained on my work

👋

Hey there!

Quick Actions

WhatsApp Direct line to me

Chat on WhatsApp

+880 1723 741224 · Replies within the hour on working days

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

mejba.13@gmail.com

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support