Skip to content

v2 breaks vue Style component inside Head component in Nuxt v3.16 #517

Closed

Description

@lehni

Environment

Nuxt v3.16 / unhead v2

Describe the bug

Up to Nuxt 3.15.4, this used to work as expected in the default.vue layout component:

<template lang="html">
  <Head>
    <Style children="body { background: red }" />
  </Head>
</template>

Nuxt v3.16 breaks this due to unhead v2. Even switching children to textContent doesn't fix it, I need to deploy an additional awkward workaround for it to work again, using <component :is="'style'">:

<template lang="html">
  <Head>
    <component :is="'Style'" textContent="body { background: red }" />
  </Head>
</template>

Activity

  1. added
    bug
    on Mar 8, 2025
  2. changed the title [-]v2 breaks vue Style component inside Head component[/-] [+]v2 breaks vue Style component inside Head component in Nuxt[/+] on Mar 8, 2025
  3. changed the title [-]v2 breaks vue Style component inside Head component in Nuxt[/-] [+]v2 breaks vue Style component inside Head component in Nuxt v3.16[/+] on Mar 8, 2025
  4. harlan-zw commented on Mar 9, 2025

    @harlan-zw
    Collaborator

    Hi, i'll look at getting this fixed as I think I accidently did drop the children support for Nuxt 3.16 (on head components).

    The workaround would be to place the CSS within the tag, this is what the tests are setup for.

    <Style>body { background: red }</Style>

    Alternatively just use

    useHead({ style: ['body { background: red }'] })
  5. lehni commented on Mar 9, 2025

    @lehni
    Author

    The main issue is not the fact that children is not supported anymore, it's that I suddenly can't use Style inside Head anymore. I need to use the weird <component :is="'Style'"/> workaround… Do you have an idea why this is happening?

    Your suggestion also only works for me, if I write it as:

    <component :is="'Style'">body { background: red }</component>

  6. lehni commented on Mar 9, 2025

    @lehni
    Author

    And if I use <component :is="'Style'">body { background: red }</component> instead of <component :is="'Style'" textContent="body { background: red }" /> I get hydration mismatch warnings: [Vue warn]: Hydration node mismatch

  7. SzymonDziak commented on Mar 16, 2025

    @SzymonDziak
    Image

    Also error trying to upgrade

  8. added a commit that references this issue on Mar 10, 2026
    44e8b5b
  9. added a commit that references this issue on Apr 5, 2026
    ab501c3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions