Building Kords: A React Chord Visualization Library
Musicians learning chords often need visual references. Tab websites show diagrams, but if you're building a music app, you need to render those diagrams yourself. That's why I'm building Kords a React component library for visualizing guitar and piano chords.
Note: Kords is currently a work in progress and not ready for production use. The API may change as development continues. Feel free to explore the code and contribute ideas!
The Problem
I wanted chord diagrams that were:
- Customizable Not static images with fixed styles
- Scalable Sharp at any size
- Lightweight No heavy dependencies
- Type-safe Good autocomplete and error checking
Existing solutions were either image-based, overly complex, or tied to specific frameworks.
The Solution
Kords provides two main components:
GuitarChordVisualizer
Here's what the guitar chord diagrams look like:


Renders guitar chord diagrams with support for:
- Fret positions (numbered)
- Open strings (0)
- Muted strings (x)
- Bar chords
- Configurable fret count
import { GuitarChordVisualizer } from 'kords';
<GuitarChordVisualizer chordName="A Minor" frets={['x', 0, 2, 2, 1, 0]} />;For bar chords like B minor, you can specify the bar:
<GuitarChordVisualizer
chordName="B Minor"
frets={['x', 2, 4, 4, 3, 2]}
barChord={{
fret: 2,
fromString: 1,
toString: 4,
}}
/>PianoChordVisualizer
And the piano visualizations:


Renders piano keyboards with highlighted notes:
import { PianoChordVisualizer } from 'kords';
<PianoChordVisualizer chordName="C Major" notes={['C4', 'E4', 'G4']} />;You can control how many octaves to display and where to start:
<PianoChordVisualizer
chordName="G Major"
notes={['G3', 'B3', 'D4', 'G4', 'B4', 'D5']}
startOctave={3}
octaveCount={3}
/>Technical Decisions
SVG for Rendering
Both components render as SVG. This means:
- Crisp at any resolution
- Easy to style with CSS
- Small file size
- No canvas context management
TypeScript Throughout
The library is fully typed. Props are explicit:
type GuitarFret = number | 'x';
interface GuitarChordProps {
frets: GuitarFret[];
chordName?: string;
fretCount?: number;
barChord?: {
fret: number;
fromString: number;
toString: number;
};
}This catches errors at compile time pass a string where a number is expected, and TypeScript tells you immediately.
Tailwind CSS v4 for Styling
Tailwind keeps the styling maintainable and customizable. Users can override styles easily if they're already using Tailwind, and the utility classes make the source readable.
Tree-Shakeable ES Modules
Import only what you need:
// Only GuitarChordVisualizer ends up in your bundle
import { GuitarChordVisualizer } from 'kords';The library exports ES modules, so modern bundlers can eliminate unused code.
The Stack
- React 19 UI components
- TypeScript 5.7 Type safety
- Vite 7 Fast builds
- Tailwind CSS 4 Styling
- Storybook 9 Component development
- Vitest 3 Testing
Trying It Locally
Since the library isn't published yet, you can clone and run it locally:
git clone https://github.com/alecorsino/kords
cd kords
pnpm install
pnpm storybookThis starts Storybook where you can interact with the components and see different chord configurations.
What's Next
Some features I'm considering:
- Scaling options Fixed sizes (S/M/L) alongside custom dimensions
- Note labels Show note names on the diagrams
- Dark mode Built-in light/dark theme support
- Audio playback Play the chord when clicked
- Different instruments Ukulele, bass (different string counts)
- Scale diagrams Full fretboard visualization for scales
Follow Along
The source is on GitHub. It's still early days, so the API will likely evolve. If you're interested in music visualization, star the repo to follow progress. Ideas and feedback are welcome.
Building tools for musicians is satisfying. There's something concrete about seeing a chord diagram render correctly it either looks right or it doesn't. No ambiguity.