Chapter 53: Vue Built-in Elements

Vue Built-in Elements (also called built-in special tags or reserved template elements).

These are very special HTML-like tags that Vue treats in a magical way. They are not normal HTML elements — they don’t exist in the browser’s DOM specification — but Vue understands them perfectly and compiles them into powerful behavior.

When you write <Transition>, <KeepAlive>, <Teleport>, <component>, <slot>, <Suspense>, etc. in a Vue template, you’re using Vue’s built-in elements.

They are always available — no import needed, no registration — and they solve very common UI and architecture problems in a clean, declarative way.

In Vue 3 (2026 standard), there are 7 main built-in elements that real developers actually use every week. Here they are, in the order of how often you’ll reach for them in practice:

1. <component :is=”…”> — Dynamic / Runtime Component (Most Used)

This is the king of built-in elements — used in almost every medium/large app.

It lets you render any component (or even native HTML tag) dynamically — the tag name is decided by a variable at runtime.

Realistic example – Tabbed dashboard

vue

→ Switch tabs → completely different component renders at the same spot → :is = the component object (imported or async)

2. <Transition> — Single-element enter/leave animation

Wraps one element that appears/disappears.

vue
CSS

→ Modal fades in/out smoothly — no JavaScript animation code needed

3. <TransitionGroup> — List (v-for) animation

Special version for lists — animates enter, leave, and move/reorder.

vue
CSS

→ Add/remove items → fade + slide → Reorder/sort/filter → items slide to new positions (.move class)

4. <KeepAlive> — Cache & preserve component state

Keeps components alive in memory when hidden (tabs, router-view).

vue

or around router-view:

vue

→ Switch tabs → form inputs, scroll position, internal state stay exactly as left

5. <Teleport> — Move DOM subtree to another location

Renders children inside another part of the DOM (usually <body>).

vue

→ Modal is logically inside your component (props, events, styles) → Physically appended to <body> → appears above everything (z-index, overflow)

6. <Suspense> — Handle async loading states

Shows fallback while child is loading (async setup / lazy components).

vue

→ Beautiful loading states for lazy routes / heavy components

7. <slot> — (technically not a component, but built-in)

Defines content insertion points — already covered in previous lessons.

vue

Quick Reference Table – Vue Built-in Components (2026)

Built-in Element Primary Purpose Most Common Use Case Frequency in Real Apps
<component :is> Dynamic component at runtime Tabs, role-based UI, wizards, CMS blocks ★★★★★ (daily)
<Transition> Single enter/leave animation Modals, dropdowns, alerts, tab content ★★★★★
<TransitionGroup> List enter/leave/move animation Todo lists, cards, search results, messages ★★★★☆
<KeepAlive> Cache component state when hidden Tabs, router-view, dynamic components ★★★★☆
<Teleport> Move content to different DOM location Modals, toasts, popovers, overlays ★★★★☆
<Suspense> Handle async loading states Lazy components, async setup ★★★☆☆ (growing fast)
<slot> Define content insertion points Reusable layouts, cards, modals ★★★★★

Pro Tips from Real Projects (Hyderabad 2026)

  • Always add :key when using dynamic :is — prevents state leakage
  • Combine <Transition> + <KeepAlive> for animated cached tabs
  • Use <Teleport to=”#modals”> + central #modals div in index.html
  • <Suspense> + defineAsyncComponent = beautiful lazy-loading DX
  • Test animations on mobile — 60Hz vs 120Hz feels very different
  • Respect prefers-reduced-motion media query for accessibility

Your mini practice task:

  1. Build a tabbed interface using <component :is> + <KeepAlive>
  2. Add <Transition> fade when switching tabs
  3. Wrap a modal in <Teleport to=”body”>
  4. Add <TransitionGroup> to a todo list inside one tab

Any part confusing? Want full examples for:

  • Animated router-view transitions?
  • Real modal system with Teleport + Transition?
  • <Suspense> + async setup example?
  • Combining all of them in one dashboard page?

Just tell me — we’ll build the next polished, animated feature together 🚀

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *