# Multi-Root Component Class Attribute Inheritance ## Rule When a Vue 3 component has multiple root elements, class and style bindings from the parent will NOT automatically fall through. You must explicitly bind `$attrs.class` or `$attrs.style` to the target element. ## Why This Matters - Vue 3 components can have multiple root elements (fragments) - Unlike single-root components, multi-root components have no automatic attribute fallthrough - Without explicit handling, classes and styles passed from parent are silently ignored - Vue will emit a runtime warning, but styles/classes simply won't apply ## Bad Code ```vue ``` ## Good Code ```vue ``` ## Accessing $attrs in script setup ```vue ``` ## Disabling Automatic Inheritance For single-root components where you want to control attribute placement: ```vue ``` ## Vue 2 to Vue 3 Migration Note In Vue 2, `$attrs` did NOT include `class` and `style`. In Vue 3, `$attrs` contains ALL attributes including `class` and `style`. This is a breaking change that affects how you handle attribute forwarding. ## References - [Fallthrough Attributes](https://vuejs.org/guide/components/attrs.html) - [Vue 3 Migration Guide - $attrs includes class & style](https://v3-migration.vuejs.org/breaking-changes/attrs-includes-class-style)