create-t3-app icon indicating copy to clipboard operation
create-t3-app copied to clipboard

feat: Add shadcn as a cli option

Open Exotica0122 opened this issue 9 months ago • 4 comments

Is your feature request related to a problem? Please describe.

Since Theo loves shadcn too it would be nice to have shadcn out of the box. The config should be setup initially when using the cli and the user can add components after using the shadcn cli commands eg: npx shadcn-ui@latest add button after the project setup.

I'd personally use this a lot.

https://www.youtube.com/watch?v=G7lZBKFFnls

Describe the solution you'd like to see

Add shadcn as one of the steps

Describe alternate solutions

N/A

Additional information

No response

Exotica0122 avatar May 09 '24 06:05 Exotica0122

Why? You can just run npx shadcn-ui init yourself after.

juliusmarminge avatar May 10 '24 20:05 juliusmarminge

Why? You can just run npx shadcn-ui init yourself after.

Running npx shadcn-ui init will completly override your tailwind.config.ts file meaning this will be lost:

extend: {
    fontFamily: {
        sans: ["var(--font-geist-sans)", ...fontFamily.sans],
    },
},

You gotta remember to add it back if you're gonna use Geist as your font. That being said, I dont think it is worth the work just because of this.

afonsopimenta avatar May 11 '24 13:05 afonsopimenta

I have a PR to fix that https://github.com/shadcn-ui/ui/pull/3558

juliusmarminge avatar May 11 '24 13:05 juliusmarminge

Should I close it if it's not worth it?

Exotica0122 avatar May 12 '24 22:05 Exotica0122

This issue might be worth to open again.

I had to take some time to set up shadcn with t3.

Few issues i ran into:

  1. module resolution and path alias:
import { Button } from "../components/ui/button.tsx";
import { Textarea } from "../components/ui/textarea.tsx";

I had to use relative imports, which isnt idea. This got me to setup the path alias manually to use @/components/ui/textarea. I had to try out other module resolutions too

  1. ignore @typescript-eslint/no-empty-interface lint rule by setting in .eslitrc.cjs

You can find my process documented in this PR here: https://github.com/lem0n4id/learnin10/pull/1

lem0n4id avatar Jun 22 '24 09:06 lem0n4id

This issue might be worth to open again.

I had to take some time to set up shadcn with t3.

Few issues i ran into:

  1. module resolution and path alias:
import { Button } from "../components/ui/button.tsx";
import { Textarea } from "../components/ui/textarea.tsx";

I had to use relative imports, which isnt idea. This got me to setup the path alias manually to use @/components/ui/textarea. I had to try out other module resolutions too

  1. ignore @typescript-eslint/no-empty-interface lint rule by setting in .eslitrc.cjs

You can find my process documented in this PR here: https://github.com/lem0n4id/learnin10/pull/1

CT3A comes with a default path alias of ~, and this is configurable throughout the setup process. The shadcn/ui docs use @ for the same purpose. Simply, just change the @ to ~?

When blindly pasting code you can expect to make some changes within your workspace to accommodate it, not everything you paste will work exactly out of the box.

And, rather than excluding eslint errors (really bad practice), it's best to try to tackle it. In the case of shadcn/ui, you can simply just remove the custom interface as it's not needed, and just use the one that it extends.

flowergardn avatar Jun 22 '24 13:06 flowergardn