---
title: "Customize with slots"
description: "Keep a packaged component and replace only the regions you care about, with the state and actions it runs on, and set its props and listen to its events."
canonical_url: "https://nuxt-backend.dev/docs/build/ui/customize/slots"
---
# Customize with slots

> Keep a packaged component and replace only the regions you care about, with the state and actions it runs on, and set its props and listen to its events.

Version: nuxt-backend 0.6.x · Tab: Build · Kind: how-to · Status: stable

Every page: [llms.txt](https://nuxt-backend.dev/llms.txt) · Skill for coding agents: [nuxt-backend](https://nuxt-backend.dev/.well-known/skills/nuxt-backend/SKILL.md)

Commands use npm; use your project's package manager.

A slot replaces one region of a packaged component and keeps the rest: its data, its rules, its other regions and its words. Vue's slots do the replacing; the package passes each slot the state and the actions the component runs on, typed, so the region you write does what the packaged one did, the way your app wants it. A slot changes one placement; to change a region everywhere, [swap the part](https://nuxt-backend.dev/docs/build/ui/customize/parts) instead.

## Replace a region

Put the component in a page of your own. At a packaged page's path, yours replaces the packaged page ([Replace a page](https://nuxt-backend.dev/docs/build/ui/customize/parts#replace-a-page)); anywhere else it is one more page. Then fill the slot for the region you want. Here `/pricing` keeps `<PricingTable>` and replaces each plan card's action:

```vue [app/pages/pricing.vue]
<script setup lang="ts">
const { t } = useLabels('pricing')
</script>

<template>
  <PricingTable heading="h1" :title="t('title')">
    <template #plan-action="{ plan, billing, isAuthenticated, loginPath, pending, subscribe, switchTo }">
      <NuxtLink v-if="!isAuthenticated" :to="loginPath">
        {{ t('signIn') }}
      </NuxtLink>
      <button
        v-else-if="billing.canManage.value && !plan.isFree && !plan.isCurrentPrice"
        type="button"
        class="cta"
        :aria-disabled="pending !== null || undefined"
        @click="pending === null && (billing.isSubscribed.value ? switchTo(plan.key) : subscribe(plan.key))"
      >
        <template v-if="pending === plan.key">
          {{ billing.isSubscribed.value ? t('changing') : t('checkingOut') }}
        </template>
        <template v-else>
          {{ billing.isSubscribed.value ? t('switch', { plan: plan.name }) : t('subscribe') }}
        </template>
      </button>
    </template>
  </PricingTable>
</template>
```

A slot replaces its region whole, so the region's cases are yours now. This one keeps the default's: a signed-out visitor gets the sign-in link (`loginPath` returns them to this page), a member who manages no billing gets no button the server would refuse, and the free plan and the current plan get no action (the default offers the current plan's cancellation there). The words come from the `pricing` labels, so your overrides and translations still apply.

## What a slot receives

Every slot of a component receives the same context: the composables it runs on (`billing`, `credits` and `pricing` here), what it derived from them (`plans`, `currentPlan`, `interval`, `pending`) and its actions (`subscribe`, `switchTo`, `cancelPlan`, `buyPack`, `openPortal`). A slot for one item adds that item: `plan` for `plan` and `plan-action`, `pack` for `pack`, and `entry` for a row of `<WorkspaceSettings>` or `<SecuritySettings>`. The context is typed with `SlotsType`, so its props type-check in your template, and slot props that are refs stay refs (`billing.canManage.value`).

Each component's slots, events and states are in [Components](https://nuxt-backend.dev/docs/reference/components), and its props in its family's page there. A few regions you are likely to reach for:

<table>
<thead>
  <tr>
    <th>
      Component
    </th>
    
    <th>
      Slot
    </th>
    
    <th>
      Replaces
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        <AuthForm>
      </code>
    </td>
    
    <td>
      <code>
        choose
      </code>
      
      , <code>
        request-code
      </code>
      
      , <code>
        verify-code
      </code>
      
      , <code>
        passkey-offer
      </code>
      
      , <code>
        recover
      </code>
    </td>
    
    <td>
      one sign-in step, with the <code>
        useLoginFlow()
      </code>
      
       object (<a href="https://nuxt-backend.dev/docs/build/auth/sign-in/custom-page">
        Build a custom sign-in page
      </a>
      
      )
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        <PricingTable>
      </code>
    </td>
    
    <td>
      <code>
        plan
      </code>
      
      , <code>
        plan-action
      </code>
      
      , <code>
        pack
      </code>
      
      , <code>
        contact
      </code>
    </td>
    
    <td>
      a whole plan card, its action, a pack card, the contact card
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        <WorkspaceSettings>
      </code>
    </td>
    
    <td>
      <code>
        workspace
      </code>
      
      , <code>
        billing
      </code>
      
      , <code>
        credits
      </code>
    </td>
    
    <td>
      a workspace row, the plan section, the credits section
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        <SecuritySettings>
      </code>
    </td>
    
    <td>
      <code>
        passkey
      </code>
      
      , <code>
        session
      </code>
    </td>
    
    <td>
      one passkey row, one session row
    </td>
  </tr>
</tbody>
</table>

## Keep what the region promised

A slot you fill takes over that region's [accessibility](https://nuxt-backend.dev/docs/build/ui/accessibility#what-a-replacement-must-keep). The example above keeps it: the button is named by its words, inside the plan's card, a group named by the plan, so a row of the same words reads apart; a busy button stays focusable (`aria-disabled`, never `disabled`) and says what it waits for; a second press while an action runs does nothing. Announce loading, empty and failure the way the region did: a status for the first two, an alert for a failure.

## Props and emits

Every prop is optional. A component resolves each one as `prop ?? appConfig.backend.* ?? built-in default`, so a prop changes one placement and app config changes them all:

```vue [app/pages/upgrade.vue]
<script setup lang="ts">
function planChanged(key: string) {
  return navigateTo({ path: '/app', query: { plan: key } })
}
</script>

<template>
  <PricingTable
    :plans="[{ key: 'pro', highlight: true }]"
    :show-packs="false"
    @plan-changed="planChanged"
  />
</template>
```

Every component that shows copy takes `labels`: its [label group](https://nuxt-backend.dev/docs/build/ui/customize/labels#the-groups) with any key set, for that placement. The events are declared as an object of validators, so `@plan-changed` and the rest type-check, and an event the reference does not list does not exist. Most components also emit `error` with the sentence a failure showed, for your own logging; [Components](https://nuxt-backend.dev/docs/reference/components) lists each one's events.

## Related

- [Components](https://nuxt-backend.dev/docs/reference/components): every component's slots, events, states and props.
- [Accessibility](https://nuxt-backend.dev/docs/build/ui/accessibility): what each component guarantees, and what a slot keeps.
- [Change copy and labels](https://nuxt-backend.dev/docs/build/ui/customize/labels): when the words are all that should change.
- [Swap a part](https://nuxt-backend.dev/docs/build/ui/customize/parts): the same region replaced everywhere, or a whole page.
- [Build a custom sign-in page](https://nuxt-backend.dev/docs/build/auth/sign-in/custom-page): the sign-in steps through slots, and from scratch.


## Sitemap

See the full [sitemap](https://nuxt-backend.dev/sitemap.md) for all pages.
