BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/boldkit/utils

Utils

boldkit/utils
FreeUtility

Utility functions for className merging

Live preview

live · rendered by the registry
Rendered by boldkit on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://boldkit.dev/r/utils.json

Source

registry/default/lib/utils.tsboldkit.dev/r/utils.json
1import { type ClassValue, clsx } from 'clsx'
2import { twMerge } from 'tailwind-merge'
3
4export function cn(...inputs: ClassValue[]) {
5 return twMerge(clsx(inputs))
6}
7
8const SAFE_URL_PROTOCOLS = new Set(['http:', 'https:', 'mailto:', 'tel:'])
9
10/** Sanitize a URL to prevent javascript: protocol injection. Returns '#' for unsafe values. */
11export function safeHref(url: string | undefined): string {
12 if (!url) return '#'
13 if (url.startsWith('/') || url.startsWith('#')) return url
14 try {
15 const parsed = new URL(url, 'https://placeholder.invalid')
16 return SAFE_URL_PROTOCOLS.has(parsed.protocol) ? url : '#'
17 } catch {
18 return '#'
19 }
20}
21
22/** Sanitize a CSS value by stripping characters that could break out of a CSS declaration. */
23export function sanitizeCssValue(value: string): string {
24 return value.replace(/[{}<>;"'\\]/g, '')
25}

What it pulls in

npm packages

  • clsx
  • tailwind-merge

Files it writes

  • registry/default/lib/utils.ts

Facts

Registry
boldkit
Type
registry:lib
Access
Free
Files written
1
Licence
MIT
First indexed
2026-08-01
Last confirmed
yesterday

Go to the source

Docs on boldkit boldkit.dev ANIBIT14/boldkit on GitHub Raw registry item This item as JSON

More from boldkit

All 94 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Chart Exportchart-exportboldkitUtilitiesFreeno deps
Math Curvesmath-curvesboldkitUtilitiesFreeno deps
Motion Coremotion-coreboldkitUtilitiesFreeno deps
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex