React Native のセットアップ
Expo アプリを一度セットアップすれば、プライベートレジストリからどのモバイル画面やブロックもインストールできます。手順は無料の beUI Native ガイドと同じで、Pro アイテムのインストール先パスを加えています。
1. ライブラリをインストールする
すべてのアイテムは Reanimated でアニメーションし、Uniwind でスタイルを適用します。SDK とバージョンが合うよう、Expo 経由でインストールしてください。Skia や Bottom Sheet など追加のライブラリが必要なアイテムもあり、それぞれのページに記載しています。
npx expo install react-native-reanimated react-native-worklets react-native-gesture-handler react-native-svg
npm install uniwind tailwindcss2. Uniwind とテーマを設定する
Metro の設定を Uniwind でラップします。Expo の Babel プリセットには Worklets プラグインが含まれているため、Expo アプリでは Babel の変更は不要です。
const { getDefaultConfig } = require("expo/metro-config");
const { withUniwindConfig } = require("uniwind/metro");
const config = getDefaultConfig(__dirname);
// Uniwind must be the outermost wrapper.
module.exports = withUniwindConfig(config, {
cssEntryFile: "./global.css",
dtsFile: "./uniwind-types.d.ts",
});プロジェクトのルートに global.css を作成します。テーマの import は初回インストール時に追加されるトークンを参照します。CSS をサブフォルダに置いている場合は、components 用の @source も追加してください。
@import "tailwindcss";
@import "uniwind";
@import "./components/beui-pro/beui/styles/theme.css";3. アプリをラップする
global.css を一度だけ import し、アプリを GestureHandlerRootView でラップします。スワイプ、ドラッグ、シートに必要です。
import "../global.css";
import { Stack } from "expo-router";
import { GestureHandlerRootView } from "react-native-gesture-handler";
export default function RootLayout() {
return (
<GestureHandlerRootView style={{ flex: 1 }}>
<Stack />
</GestureHandlerRootView>
);
}4. レジストリに接続してインストールする
Expo アプリで shadcn CLI を使うには、完全な components.json が必要です。これをプロジェクトのルートに追加し、アカウントの BEUI_PRO_TOKEN を使ってインストールしてください。
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "new-york",
"rsc": false,
"tsx": true,
"tailwind": {
"config": "",
"css": "global.css",
"baseColor": "neutral",
"cssVariables": true
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils",
"lib": "@/lib",
"hooks": "@/hooks"
},
"registries": {
"@beui-pro": {
"url": "https://pro.beui.dev/r/{name}.json",
"headers": {
"Authorization": "Bearer ${BEUI_PRO_TOKEN}"
}
}
}
}export BEUI_PRO_TOKEN="beui_live_xxxxxxxxxxxx"
npx shadcn@latest add @beui-pro/native-tab-barアイテムは、import する共有 beUI ファイルと並んで components/beui-pro に配置されます。ファイルで受け取りたい場合は、ダッシュボードから個別またはまとめてダウンロードできます。
global.css
metro.config.js
components.json
components/
beui-pro/
premium/
blocks/tab-bar/
beui/
hooks/
styles/
motion.ts
theme.css5. Inter を読み込む(任意)
Pro アイテムは font-sans-medium などのクラスで文字を設定しています。デモ映像と同じ見た目にするには、global.css のテーマの後にこれらのフォントファミリーを追加し、レンダリング前に 4 つのウェイトを読み込んでください。省略するとシステムフォントが使われます。
npx expo install @expo-google-fonts/inter expo-font@theme {
--font-sans: "Inter_400Regular";
--font-sans-medium: "Inter_500Medium";
--font-sans-semibold: "Inter_600SemiBold";
--font-sans-bold: "Inter_700Bold";
}import {
Inter_400Regular,
Inter_500Medium,
Inter_600SemiBold,
Inter_700Bold,
useFonts,
} from "@expo-google-fonts/inter";
const [loaded] = useFonts({
Inter_400Regular,
Inter_500Medium,
Inter_600SemiBold,
Inter_700Bold,
});