Line data Source code
1 : import { computed, useAttrs } from 'vue'
2 :
3 : import type { ClassValue } from 'clsx'
4 :
5 : /**
6 : * Splits `class` out of `$attrs` so wrappers can merge it with `cn()` onto an
7 : * inner element while the remaining attrs fall through untouched.
8 : */
9 1170 : export function useAttrsClass() {
10 1170 : const attrs = useAttrs()
11 1170 : return {
12 : attrsClass: computed(() => attrs.class as ClassValue),
13 : attrsWithoutClass: computed(() => {
14 1170 : const { class: _class, ...rest } = attrs
15 1170 : return rest
16 : })
17 : }
18 : }
|