Chapter 48: Vue Built-in Components

Vue’s Built-in Components.

These are special components that Vue gives you for free — you don’t need to install anything, import anything, or register anything. They are always available in any Vue template, and they solve very common problems in a clean, declarative way.

In Vue 3 (2026 standard), there are 7 main built-in components that you will actually use in real projects. (There are a couple more internal ones, but 99% of the time you only care about these.)

Here they are, in the order of how often you will use them:

  1. <component :is=”…”> → Dynamic Components
  2. <Transition> → Single-element enter/leave animations
  3. <TransitionGroup> → List (v-for) animations
  4. <KeepAlive> → Cache components (great for tabs/router-view)
  5. <Teleport> → Move content to another part of the DOM (modals, toasts)
  6. <Suspense> → Handle async setup / loading states
  7. <slot> → (technically not a component, but built-in slot syntax)

Let’s go through them one by one — with real, practical examples and when/why you reach for each.

1. <component :is=”…”> – Dynamic Components (Most Used)

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

It lets you render a different component at runtime based on a variable.

Realistic example – Tabbed interface

vue

When you use <component :is> every week

  • Tabbed dashboards / settings pages
  • Role-based views (admin vs user dashboard)
  • Wizard / multi-step forms
  • CMS / page-builder rendering
  • A/B testing variants
  • Dynamic content from API/JSON

2. <Transition> – Single Element Enter/Leave

Wraps one element that appears/disappears (v-if / v-show / v-if inside router-view).

vue
CSS

Shorthand names you will see everywhere

  • fade → opacity fade
  • slide → slide in/out
  • scale → zoom in/out
  • bounce → fun bounce effect

3. <TransitionGroup> – List Animations (v-for)

This is the one that makes todo lists, cards, search results feel premium.

vue
CSS

4. <KeepAlive> – Cache & Preserve State

Wraps dynamic components / router-view so they remember state when hidden.

vue

→ Tabs remember form inputs, scroll position, internal state — huge UX win.

5. <Teleport> – Move Content to Another DOM Location

Renders children in a different part of the DOM tree (usually body).

vue

Perfect for:

  • Modals / dialogs
  • Toasts / notifications
  • Full-screen overlays
  • Tooltips that break out of scroll containers

6. <Suspense> – Handle Async Setup / Loading

Shows fallback while child components are loading (async setup or lazy components).

vue

Very useful with:

  • defineAsyncComponent
  • async setup()
  • Lazy routes in Vue Router

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

Component Primary Purpose Most Common Wrapper For Real Frequency (daily use)
<component :is> Dynamic / runtime component selection Tabs, role-based UI, wizards ★★★★★ (every large app)
<Transition> Single enter/leave or state change animation Modals, alerts, dropdowns, v-if blocks ★★★★★
<TransitionGroup> List enter/leave/move animations Todo lists, cards, search results ★★★★☆
<KeepAlive> Cache component state when hidden Tabs, router-view, dynamic components ★★★★☆
<Teleport> Move content to different DOM location Modals, toasts, popovers ★★★★☆
<Suspense> Handle async loading states Lazy components, async setup ★★★☆☆ (growing)

Pro Tips from Real Projects (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 🚀

Happy built-in-component-ing from Hyderabad! 💙

You may also like...

Leave a Reply

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