Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
This repository was archived by the owner on Sep 17, 2022. It is now read-only.
/cxPublic archive

Concatenate your classes (with shortcuts) 🔗

License

NotificationsYou must be signed in to change notification settings

joe-bell/cx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚠️This project has been deprecated in favour ofcva

cx 🔗

Concatenate your classes (with shortcuts)

NPM VersionTypes IncludedMinizipped SizeMIT LicenseNPM DownloadsFollow @joebell_ on Twitter


cx is atiny function that mimics and extends the popularclassnames utility with"shortcuts" to re-use common classes (with TypeScript autocompletion)

💡 Works especially nicely withTailwind IntelliSense

Setup

  1. Install the package via your favourite package manager:

    npm i @joebell/cx
  2. Create a customcx function for later use.

    Common styles can be defined in theshortcuts and accessed by it's"key" for re-use later.

    ⚠️FYI: At this point in time, your shortcuts must be a flat object with no nested keys.

    // styles/index.tsimport{createCx}from"@joebell/cx";constshortcuts={// Components"c-container":["block","max-w-5xl","mx-auto","px-4"],// Utilities"u-border":["border-dashed","border-black"],};exportconstcx=createCx(shortcuts);
  3. Importcx into your component or layout.

    For example, in React.js:

    // pages/index.tsximport{cx}from"../styles";constPage:React.FC=({ children})=>(<mainclassName={cx("c-container","mt-4")}>{children}</main>);

    returns…

    <mainclass="block max-w-5xl mx-auto px-4 mt-4"></main>

    💡Tip: If you're having issues withTailwind IntelliSense in VSCode, try reloading the window

Acknowledgements

Without these projects/people, this project wouldn't exist…


[8]ページ先頭

©2009-2025 Movatter.jp