RAFT
#30

What is a macro?

Components and Patterns · Working

What is this skill?

A macro is a reusable Nunjucks code block that accepts parameters and outputs HTML. GOV.UK Frontend components are implemented as macros, allowing you to configure them with different options.

Why is it important?

  • Reusability – Write once, use many times with different parameters
  • Consistency – Same component looks identical everywhere
  • Configuration – Pass different options to customise behaviour
  • Foundation – Understanding macros unlocks the full design system

Where to learn more