Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply VueUse composables in Vue 3/Nuxt projects to replace custom implementations with battle-tested utilities.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/useChangeCase.md
1---2category: '@Integrations'3---45# useChangeCase67Reactive wrapper for [`change-case`](https://github.com/blakeembrey/change-case).89Subsitutes `useCamelCase`, `usePascalCase`, `useSnakeCase`, `useSentenceCase`, `useCapitalize`, etc.1011## Install1213```bash14npm i change-case@^515```1617## Usage1819```ts20import { useChangeCase } from '@vueuse/integrations/useChangeCase'2122// `changeCase` will be a computed23const changeCase = useChangeCase('hello world', 'camelCase')24changeCase.value // helloWorld25changeCase.value = 'vue use'26changeCase.value // vueUse27// Supported methods28// export {29// camelCase,30// capitalCase,31// constantCase,32// dotCase,33// headerCase,34// noCase,35// paramCase,36// pascalCase,37// pathCase,38// sentenceCase,39// snakeCase,40// } from 'change-case'41```4243or passing a `ref` to it, the returned `computed` will change along with the source ref's changes.4445Can be passed into `options` for customization4647```ts48import { useChangeCase } from '@vueuse/integrations/useChangeCase'49import { shallowRef } from 'vue'5051const input = shallowRef('helloWorld')52const changeCase = useChangeCase(input, 'camelCase', {53delimiter: '-',54})55changeCase.value // hello-World56input.value = 'vue use'57changeCase.value // vue-Use58```5960## Type Declarations6162```ts63type EndsWithCase<T> = T extends `${infer _}Case` ? T : never64type FilterKeys<T> = {65[K in keyof T as K extends string ? K : never]: EndsWithCase<K>66}67type ChangeCaseKeys = FilterKeys<typeof changeCase>68export type ChangeCaseType = ChangeCaseKeys[keyof ChangeCaseKeys]69export declare function useChangeCase(70input: MaybeRef<string>,71type: MaybeRefOrGetter<ChangeCaseType>,72options?: MaybeRefOrGetter<Options> | undefined,73): WritableComputedRef<string>74export declare function useChangeCase(75input: MaybeRefOrGetter<string>,76type: MaybeRefOrGetter<ChangeCaseType>,77options?: MaybeRefOrGetter<Options> | undefined,78): ComputedRef<string>79```80