kebabCase

Convert a string to kebab-case, lowercasing words and joining them with hyphens, ideal for URLs, file names, and CSS classes.

Usage

Converts a string to kebab-case format.

import { kebabCase } from '@movk/core'

kebabCase('firstName') // => 'first-name'
kebabCase('First Name') // => 'first-name'
kebabCase('first_name') // => 'first-name'
kebabCase('XMLHttpRequest') // => 'xml-http-request'

API

kebabCase(str: string): string

Parameters

str
string required
The string to convert.

Returns

string
Returns the string in kebab-case format.

Changelog

No recent changes
Copyright © 2024 - 2026 YiXuan - MIT License