Components
- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Attachment
- Avatar
- Badge
- Breadcrumb
- Bubble
- Button
- Button Group
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Collapsible
- Combobox
- Command
- Context Menu
- Data Table
- Date Picker
- Dialog
- Direction
- Drawer
- Dropdown Menu
- Empty
- Field
- Hover Card
- Input
- Input Group
- Input OTP
- Item
- Kbd
- Label
- Marker
- Menubar
- Message
- Message Scroller
- Native Select
- Navigation Menu
- Pagination
- Popover
- Progress
- Questionnaire
- Radio Group
- Resizable
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toast
- Toggle
- Toggle Group
- Tooltip
- Typography
Sections
@shadcn/react
@shadcn/helpers
Utilities
注: このガイドは Tailwind CSS v3 を使用する Gatsby 用です。新しいプロジェクトでは、Tailwind CSS v4 をサポートする他のフレームワークの使用をお勧めします。
プロジェクトの作成#
まず、create-gatsby を使用して新しい Gatsby プロジェクトを作成します。
npm init gatsbyTypeScript と Tailwind CSS を使用するように Gatsby プロジェクトを構成する#
プロジェクトを構成するため、いくつかの質問が表示されます:
✔ What would you like to call your site?
· your-app-name
✔ What would you like to name the folder where your site will be created?
· your-app-name
✔ Will you be using JavaScript or TypeScript?
· TypeScript
✔ Will you be using a CMS?
· Choose whatever you want
✔ Would you like to install a styling system?
· Tailwind CSS
✔ Would you like to install additional features with other plugins?
· Choose whatever you want
✔ Shall we do this? (Y/n) · Yestsconfig.json ファイルを編集する#
パスを解決するため、次のコードを tsconfig.json ファイルに追加します。
{
"compilerOptions": {
// ...
"baseUrl": ".",
"paths": {
"@/*": [
"./src/*"
]
}
// ...
}
}gatsby-node.ts ファイルの作成#
プロジェクトのルートに gatsby-node.ts ファイルがまだ存在しない場合は作成し、アプリがパスを解決できるように、以下のコードを gatsby-node ファイルに追加します。
import * as path from "path"
export const onCreateWebpackConfig = ({ actions }) => {
actions.setWebpackConfig({
resolve: {
alias: {
"@/components": path.resolve(__dirname, "src/components"),
"@/lib/utils": path.resolve(__dirname, "src/lib/utils"),
},
},
})
}CLI を実行します#
shadcn init コマンドを実行して、プロジェクトをセットアップします。
pnpm dlx shadcn@latest init
以上です#
これで、プロジェクトへのコンポーネントの追加を開始できます。
pnpm dlx shadcn@latest add button
上記のコマンドは、Button コンポーネントをプロジェクトに追加します。次に、次のようにインポートできます。
import { Button } from "@/components/ui/button"
export default function Home() {
return (
<div>
<Button>Click me</Button>
</div>
)
}shadcn/uiアプリをVercelにデプロイ
OpenAI、Sonos、Adobeなどに採用されています。
Vercelは、アプリや機能を大規模にデプロイするためのツールと インフラを提供します。
Vercelにデプロイ