Guide
How to use Tailwind Capacitor in Capacitor
Tailwind Capacitor (shadcn registry)
Tailwind Capacitor ships Tailwind CSS v4 utilities for Capacitor safe areas and platform variants, plus Vue, React, and Angular UI components, as a shadcn registry. You copy source into your app with the shadcn CLI.
Install commands on Capgo track Cap-go/tailwind-capacitor main at commit 9791d43d67279d7725d6a1f7865ff10deaf36ba5 (merge commit for PR #130).
Live component demo
Open the interactive registry demo to preview every registry item with iOS or Material styling and light or dark mode.
Use the framework tabs on the demo page or the docs getting started for Vue (shadcn-vue), React (shadcn), and Angular (registry-add via the tailwind-capacitor package) install commands.
Prerequisites
- Vue 3 app with Tailwind CSS v4 (
@tailwindcss/viteor PostCSS) - A project-level
components.jsonfrom the shadcn-vue CLI (npx shadcn-vue@latest init) - Path alias
@/*pointing at yoursrc/folder - No
tailwind.config.jsrequired
Install base styles
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
In your app global stylesheet, replace the @import "tailwindcss" line with the capacitor bundle import. Keep your other custom CSS. The bundle already includes Tailwind, so do not keep a separate Tailwind import:
@import '@/capacitor/styles/tailwind-capacitor.css';
Install components used in the example
App, Page, Navbar, and Button are separate registry items. Install each one:
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
Components land under src/capacitor/vue/components/. The provider lands under src/capacitor/vue/shared/. Shared classes land under src/capacitor/shared/. Icons land under src/capacitor/vue/components/icons/.
Vue usage
Import the files that shadcn add writes. The library example app generates @/capacitor/index.js as a convenience barrel. That file is not created when you install registry items into your own project.
Button has no fill prop. The default style is solid. Use the boolean outline or clear props for the other styles.
<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
- Put
safe-areason the root page shell. - Use
pt-safe,pb-safe,pl-safe, andpr-safefor insets. There is nopx-safeutility. - Platform variants:
ios:,android:,capacitor:,mobile:.
Registry hosting
Built JSON files live in public/r/ (Vue), public/r/react/, and public/r/angular/ on GitHub:
https://raw.githubusercontent.com/Cap-go/tailwind-capacitor/<commit>/public/r/<name>.json