Skip to content

Commit

Permalink
Merge pull request #3 from devneill/dev
Browse files Browse the repository at this point in the history
Add className prop
  • Loading branch information
devneill authored Nov 12, 2024
2 parents 549a817 + a329832 commit e9ad725
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/long-hotels-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'osstarter': patch
---

Support className prop
49 changes: 48 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,51 @@

A starter template for a TypeScript, React & Tailwind package.

Based on https://www.totaltypescript.com/how-to-create-an-npm-package by Matt Pocock.
Extended from https://www.totaltypescript.com/how-to-create-an-npm-package by @mattpocock.

## Make it your own and publish to npm

Copy this template, rename the package and start building your own React & Tailwind package.

1.Make a new branch

1. Add your changes
1. Run `npx changeset` to create a changeset.
1. Push your changes
1. Merge your changes to `main` - this will create a new Version Packages PR.
1. Review the Version Packages PR and merge it - this will publish your package to npm.

### Installation

Install the package with pnpm/npm/yarn.

```bash
npm i my-new-package
```

Add it to your Tailwind config.

```js
// tailwind.config.js

module.exports = {
content: [
'./src/**/*.{js,jsx,ts,tsx}',
// Add this line
'./node_modules/my-new-package/**/*.{js,jsx,ts,tsx}',
],
// ... rest of config
};
```

### Usage

Quick start

```tsx
import { MyComponent } from 'my-new-package';

function MyApp() {
return <MyComponent />;
}
```
10 changes: 8 additions & 2 deletions src/MyComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import React from 'react';
import { cn } from './lib/utils.js';

export function MyComponent() {
export interface MyComponentProps {
className?: string;
}

export function MyComponent({ className }: MyComponentProps) {
return (
<div className={cn('p-6', 'bg-stone-900', 'rounded-lg')}>Hello world!</div>
<div className={cn('p-6 bg-stone-900 rounded-lg', className)}>
Hello world!
</div>
);
}

0 comments on commit e9ad725

Please sign in to comment.