Anleitung
So verwendest du Tailwind Capacitor in Capacitor
Tailwind Capacitor (shadcn-Registry)
Tailwind Capacitor bietet Tailwind CSS v4 Utilities für Capacitor Safe Areas und Plattform-Varianten sowie UI-Komponenten für Vue, React und Angular als shadcn-Registry. Du kopierst den Quellcode mit dem shadcn-CLI in deine App.
Installationsbefehle auf Capgo tracken Cap-go/tailwind-capacitor Haupt bei Commit 9791d43d67279d7725d6a1f7865ff10deaf36ba5 (Merge-Commit für PR #130).
Live-Komponenten-Demo
Öffne die interaktive Registry-Demo um jeden Registry-Eintrag mit iOS- oder Material-Styling sowie in Hell- oder Dunkelmodus zu previewen.
Nutze die Framework-Tabs auf der Demo-Seite oder den Doku Getting Started für Vue (shadcn-vue), React (shadcn) und Angular (registry-add über das tailwind-capacitor-Paket) Installationsbefehle.
Voraussetzungen
- Vue-3-App mit Tailwind CSS v4 (
@tailwindcss/viteoder PostCSS) - Ein projektbezogenes
components.jsonvom shadcn-vue CLI (npx shadcn-vue@latest init) - Path-Alias
@/*der auf deinsrc/Ordner - Nein
tailwind.config.jserforderlich
Basis-Styles installieren
npx shadcn-vue@latest add https://raw.githubusercontent.com/Cap-go/tailwind-capacitor/9791d43d67279d7725d6a1f7865ff10deaf36ba5/public/r/capacitor-tailwind.json
npx shadcn-vue@latest add https://raw.githubusercontent.com/Cap-go/tailwind-capacitor/9791d43d67279d7725d6a1f7865ff10deaf36ba5/public/r/capacitor-provider.json
npx shadcn-vue@latest add https://raw.githubusercontent.com/Cap-go/tailwind-capacitor/9791d43d67279d7725d6a1f7865ff10deaf36ba5/public/r/capacitor-shared.json
npx shadcn-vue@latest add https://raw.githubusercontent.com/Cap-go/tailwind-capacitor/9791d43d67279d7725d6a1f7865ff10deaf36ba5/public/r/capacitor-icons.json
Ersetze in deinem globalen App-Stylesheet das @import "tailwindcss" Zeile mit dem capacitor-Bundle-Import. Behalte deinen anderen Custom-CSS bei. Das Bundle enthält bereits Tailwind, daher keinen separaten Tailwind-Import behalten:
@import '@/capacitor/styles/tailwind-capacitor.css';
Komponenten für das Beispiel installieren
App, Page, Navbar, und Button sind separate Registry-Einträge. Jeden einzeln installieren:
npx shadcn-vue@latest add https://raw.githubusercontent.com/Cap-go/tailwind-capacitor/9791d43d67279d7725d6a1f7865ff10deaf36ba5/public/r/capacitor-app.json
npx shadcn-vue@latest add https://raw.githubusercontent.com/Cap-go/tailwind-capacitor/9791d43d67279d7725d6a1f7865ff10deaf36ba5/public/r/capacitor-page.json
npx shadcn-vue@latest add https://raw.githubusercontent.com/Cap-go/tailwind-capacitor/9791d43d67279d7725d6a1f7865ff10deaf36ba5/public/r/capacitor-navbar.json
npx shadcn-vue@latest add https://raw.githubusercontent.com/Cap-go/tailwind-capacitor/9791d43d67279d7725d6a1f7865ff10deaf36ba5/public/r/capacitor-button.json
Komponenten landen unter src/capacitor/vue/components/. Der Provider landet unter src/capacitor/vue/shared/. Gemeinsame Klassen landen unter src/capacitor/shared/. Icons landen unter src/capacitor/vue/components/icons/.
Vue-Nutzung
Importiere die Dateien, die shadcn add schreibt. Die Beispiel-App der Bibliothek generiert @/capacitor/index.js als bequemen Barrel. Diese Datei wird nicht erstellt, wenn du Registry-Einträge in dein eigenes Projekt installierst.
Button hat keine fill -Prop. Der Standardstil ist solid. Verwende die booleschen outline oder clear -Props für die anderen Stile.
<script setup>
import TailwindCapacitorProvider from '@/capacitor/vue/shared/TailwindCapacitorProvider.vue'
import App from '@/capacitor/vue/components/App.vue'
import Page from '@/capacitor/vue/components/Page.vue'
import Navbar from '@/capacitor/vue/components/Navbar.vue'
import Button from '@/capacitor/vue/components/Button.vue'
</script>
<template>
<TailwindCapacitorProvider>
<App theme="ios" class="safe-areas">
<Page>
<Navbar title="Home" />
<Button>Continue</Button>
</Page>
</App>
</TailwindCapacitorProvider>
</template>
Safe Areas
- Füge
safe-areasauf der Root-Page-Shell. - Nutzt
pt-safe,pb-safe,pl-safe, undpr-safefür Insets. Es gibt keinepx-safe-Utility. - Plattform-Varianten:
ios:,android:,capacitor:,mobile:.
Registry-Hosting
Die erstellten JSON-Dateien liegen in public/r/ (Vue), public/r/react/, und public/r/angular/ auf GitHub:
https://raw.githubusercontent.com/Cap-go/tailwind-capacitor/<commit>/public/r/<name>.json