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
新しいプロジェクトを開始しますか? カスタム テーマ、Base UI または Radix、アイコン ライブラリを備えた完全に構成された Vite アプリを作成するには、shadcn/create を使用します。
プロジェクトの作成#
--rtl フラグと vite テンプレートを使用して、新しいプロジェクトを作成します。
shadcn/create を使ってプロジェクトを作成済みの場合、この手順は省略できます。
pnpm dlx shadcn@latest create --template vite --rtl
これにより、rtl: true フラグを持つ components.json ファイルが作成されます。
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "base-nova",
"rtl": true
}DirectionProvider を追加#
dir="rtl" 属性と lang="ar" 属性を index.html の html タグに追加します。lang="ar" は対象言語に更新してください。
<!doctype html>
<html lang="ar" dir="rtl">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>次に、main.tsx で direction="rtl" prop を持つ DirectionProvider コンポーネントでアプリをラップします。
import { StrictMode } from "react"
import { createRoot } from "react-dom/client"
import { DirectionProvider } from "@/components/ui/direction"
import App from "./App"
import "./index.css"
createRoot(document.getElementById("root")!).render(
<StrictMode>
<DirectionProvider direction="rtl">
<App />
</DirectionProvider>
</StrictMode>
)フォントの追加#
最適な RTL 体験のため、対象言語を適切にサポートするフォントの使用を推奨します。Noto はこの用途に適したフォント ファミリーで、Inter や Geist ともよく合います。
Fontsource を使用してフォントをインストールします。
pnpm add @fontsource-variable/noto-sans-arabic
index.css でフォントをインポートします。
@import "tailwindcss";
@import "tw-animate-css";
@import "shadcn/tailwind.css";
@import "@fontsource-variable/noto-sans-arabic";
@theme inline {
--font-sans: "Noto Sans Arabic Variable", sans-serif;
}その他の言語、たとえばヘブライ語には @fontsource-variable/noto-sans-hebrew を使えます。
コンポーネントの追加#
これでプロジェクトにコンポーネントを追加する準備ができました。CLI が RTL サポートを処理します。
pnpm dlx shadcn@latest add item
shadcn/uiアプリをVercelにデプロイ
OpenAI、Sonos、Adobeなどに採用されています。
Vercelは、アプリや機能を大規模にデプロイするためのツールと インフラを提供します。
Vercelにデプロイ