Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,31 @@ jobs:
e2e:
name: End-to-end
runs-on: ubuntu-latest
# Every docs page loads the session, favorites and comments, which are backed by Postgres. Run
# against a real throwaway database so those calls succeed instead of returning 500.
services:
postgres:
image: postgres:16
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: modus_ui
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U postgres"
--health-interval 5s
--health-timeout 5s
--health-retries 10
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/modus_ui?schema=modus_ui
DIRECT_URL: postgresql://postgres:postgres@localhost:5432/modus_ui?schema=modus_ui
# Throwaway values: nothing in CI signs anyone in, but Better Auth needs them to start.
BETTER_AUTH_SECRET: ci-only-secret-0123456789abcdef0123456789abcdef
BETTER_AUTH_URL: http://localhost:3100
GOOGLE_OAUTH_CLIENT_ID: ci-client-id
GOOGLE_OAUTH_CLIENT_SECRET: ci-client-secret
# One machine loads ~1,700 pages; Better Auth's per-IP limit would answer some with 429.
AUTH_RATE_LIMIT: "off"
steps:
- uses: actions/checkout@v5
- uses: pnpm/action-setup@v4
Expand All @@ -69,6 +94,7 @@ jobs:
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm exec playwright install --with-deps chromium
- run: pnpm db:migrate
- run: pnpm test:e2e
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
Expand Down
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ When working in this repository, you MUST follow these rules:

1. **Tech Stack**: Use TypeScript (`.tsx`), Tailwind CSS variables (e.g. `bg-background`, `text-primary`), and `framer-motion` for all animations. Do NOT use `gsap`.
2. **Utilities**: Always use the `cn()` utility from `@/lib/utils` for class name merging.
3. **CLI**: Documentation must instruct users to use `npx @modus-ui/cli add <component>`. Do NOT use `npx shadcn`, `npx react-ui-component` or the unscoped `npx modus-ui` (that npm package belongs to someone else).
3. **CLI**: Documentation must instruct users to use `npx @modus-ui/cli add <component>`; write the npm form in the docs and the site shows pnpm, yarn and bun tabs for it (`src/lib/install.ts`). Do NOT use `npx shadcn`, `npx react-ui-component` or the unscoped `npx modus-ui` (that npm package belongs to someone else).
4. **Registration**: Start new components with `pnpm new:component --name <slug> --category <Category>`. Register a component in exactly two places: its entry (name, title, category, dependencies, files) in `src/registry/index.ts` and its demo in `src/registry/demos.ts`. The sidebar, components index and previews are derived from these; never hand-edit lists there.
5. **Theme colors**: Tokens are bare HSL channels, so use `hsl(var(--primary))`, never `var(--primary)`. On a `<canvas>`, resolve colors through `getComputedStyle` first.
6. **Native components**: Components in the `Native` category are React Native (Expo), with `platform: "native"` and `dependencies: []` in the registry. Import only from `react-native`; use `Animated` and `PanResponder`, not `framer-motion`, `className` or `cn()`. Take colors through a `colors?: Partial<...>` prop with plain defaults (there are no CSS variables in React Native), and read the system setting with `AccessibilityInfo.isReduceMotionEnabled()`. Use `NATIVE_DRIVER = Platform.OS !== "web"` and `userSelect: "none"` on draggable surfaces so the docs preview works with a mouse. The demo wraps its content in `NativeStage` (`src/registry/native-stage.tsx`) and is registered with `dynamic(..., { ssr: false })` in `demos.ts`.
6. **React Native components**: Components in the `React Native` category are React Native (Expo), with `platform: "native"` and `dependencies: []` in the registry. Import only from `react-native`; use `Animated` and `PanResponder`, not `framer-motion`, `className` or `cn()`. Take colors through a `colors?: Partial<...>` prop with plain defaults (there are no CSS variables in React Native), and read the system setting with `AccessibilityInfo.isReduceMotionEnabled()`. Use `NATIVE_DRIVER = Platform.OS !== "web"` and `userSelect: "none"` on draggable surfaces so the docs preview works with a mouse. The demo wraps its content in `NativeStage` (`src/registry/native-stage.tsx`), which draws a phone frame around it; its `height` is the screen area between the status bar and the home indicator and is registered with `dynamic(..., { ssr: false })` in `demos.ts`.
31 changes: 20 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ Modus UI is **not** a package you import from. You own the code: add a component
npx @modus-ui/cli add blur-text
```

Use whichever package manager you prefer. Each component page has a tab for each:

| Package manager | Command |
| :-------------- | :------------------------------------- |
| npm | `npx @modus-ui/cli add blur-text` |
| pnpm | `pnpm dlx @modus-ui/cli add blur-text` |
| yarn | `yarn dlx @modus-ui/cli add blur-text` |
| bun | `bunx @modus-ui/cli add blur-text` |

The CLI writes the component into your project and lists the npm packages it needs. Every component page shows its own command.

To copy and paste instead, open the **Code** tab on any component page and save the file as `components/ui/<name>.tsx`. Components import `cn()` from `@/lib/utils`:
Expand Down Expand Up @@ -83,17 +92,17 @@ For Cursor, Windsurf or VS Code setup, see [`packages/mcp`](packages/mcp). The d

## Components

| Category | Components |
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| **Navigation** | Liquid Tabs, Flowing Menu, Morphing Navbar, Floating Dock, Notch Footer, Process Stepper |
| **Actions** | Magnet, Magic Button, Animated Button, Pulse Button |
| **Data Display** | Bounce Cards, Masonry Grid, Animated List, Kinetic Carousel, Expandable Showcase, Focus Card, Rotating Card, Tilt Card |
| **Backgrounds** | Cursor Grid, Waves, Letter Glitch, Aurora Background, Circuit Background, Grid Motion |
| **Typography** | Scroll Velocity, Text Pressure, True Focus, Gradient Text, Blur Text, Split Text, Decrypted Text, Shimmer Text, Floating Text |
| **Components** | Scratch to Reveal, Stack, Star Border, Tilted Card, Pixel Card, Click Spark, Spotlight Card, Border Glow |
| **Native** | Swipe Actions, Snap Sheet, Glide Segments, Swipe Deck, Fan Menu, Pin Pad |

**Native** components are React Native (Expo) files that import only `react-native`, so they need no extra packages. Install them the same way (`npx @modus-ui/cli add swipe-actions`); the docs preview them live in the browser through react-native-web.
| Category | Components |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Navigation** | Liquid Tabs, Flowing Menu, Morphing Navbar, Floating Dock, Notch Footer, Process Stepper |
| **Actions** | Magnet, Magic Button, Animated Button, Pulse Button |
| **Data Display** | Bounce Cards, Masonry Grid, Animated List, Kinetic Carousel, Expandable Showcase, Focus Card, Rotating Card, Tilt Card |
| **Backgrounds** | Cursor Grid, Waves, Letter Glitch, Aurora Background, Circuit Background, Grid Motion |
| **Typography** | Scroll Velocity, Text Pressure, True Focus, Gradient Text, Blur Text, Split Text, Decrypted Text, Shimmer Text, Floating Text |
| **Components** | Scratch to Reveal, Stack, Star Border, Tilted Card, Pixel Card, Click Spark, Spotlight Card, Border Glow |
| **React Native** | Swipe Actions, Snap Sheet, Glide Segments, Swipe Deck, Fan Menu, Pin Pad, Flick Toast, Fold Panel, Snap Carousel, Slide Switch, Shimmer Block, Parallax Header, Bubble Tab Bar, Roll Number, Star Rating, Value Slider, Expand Search, Intro Pager, Drag List, Long Press Menu, Slide Confirm, Calendar Strip, Step Tracker, Chip Input, Typing Dots, Marquee Ticker, Choice Chips, Hold Stepper |

**React Native** components are Expo files that import only `react-native`, so they need no extra packages. Install them the same way (`npx @modus-ui/cli add swipe-actions`); the docs preview them live in the browser through react-native-web.

## Documentation

Expand Down
2 changes: 2 additions & 0 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ npx @modus-ui/cli add blur-text magnet
npx @modus-ui/cli list
```

With another package manager, swap `npx` for its runner: `pnpm dlx`, `yarn dlx` or `bunx`.

## Commands

### `add <name...>`
Expand Down
15 changes: 15 additions & 0 deletions public/registry/bubble-tab-bar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "bubble-tab-bar",
"title": "Bubble Tab Bar",
"category": "React Native",
"type": "components:ui",
"platform": "native",
"added": "2026-11-02",
"dependencies": [],
"files": [
{
"path": "registry/bubble-tab-bar.tsx",
"content": "import { useEffect, useMemo, useRef, useState, type ReactNode } from \"react\";\nimport {\n AccessibilityInfo,\n Animated,\n Platform,\n Pressable,\n StyleSheet,\n Text,\n View,\n type LayoutChangeEvent,\n type StyleProp,\n type ViewStyle,\n} from \"react-native\";\n\nconst NATIVE_DRIVER = Platform.OS !== \"web\";\nconst PAD = 6;\nconst TAB_HEIGHT = 52;\nconst INACTIVE_WIDTH = 56;\nconst STRETCH = 16;\n\nexport interface BubbleTab {\n id: string;\n label: string;\n /** The tab's icon, or a function that receives the tab's current color and returns it. */\n icon: ReactNode | ((color: string) => ReactNode);\n}\n\nexport interface BubbleTabBarColors {\n bar: string;\n pill: string;\n active: string;\n inactive: string;\n}\n\nconst DEFAULT_COLORS: BubbleTabBarColors = {\n bar: \"#ffffff\",\n pill: \"#4f46e5\",\n active: \"#ffffff\",\n inactive: \"#6b7280\",\n};\n\nfunction useReduceMotion() {\n const [reduce, setReduce] = useState(false);\n useEffect(() => {\n AccessibilityInfo.isReduceMotionEnabled().then(setReduce);\n const sub = AccessibilityInfo.addEventListener(\"reduceMotionChanged\", setReduce);\n return () => sub.remove();\n }, []);\n return reduce;\n}\n\nexport interface BubbleTabBarProps {\n tabs: BubbleTab[];\n /** The `id` of the selected tab. */\n value: string;\n onChange: (id: string) => void;\n colors?: Partial<BubbleTabBarColors>;\n style?: StyleProp<ViewStyle>;\n}\n\ninterface TabValues {\n width: Animated.Value;\n label: Animated.Value;\n}\n\n/**\n * A bottom tab bar where a rounded pill slides behind the selected tab, stretching a little as it\n * travels. The selected tab opens up to show its label next to the icon; the others stay icon-only.\n * Every tab is at least 44 points tall and wide, and the bar is a tablist to screen readers.\n */\nexport function BubbleTabBar({ tabs, value, onChange, colors, style }: BubbleTabBarProps) {\n const palette = { ...DEFAULT_COLORS, ...colors };\n const reduceMotion = useReduceMotion();\n const [barWidth, setBarWidth] = useState(0);\n\n const index = Math.max(\n 0,\n tabs.findIndex((tab) => tab.id === value),\n );\n const count = tabs.length;\n const inner = Math.max(0, barWidth - PAD * 2);\n const activeWidth = Math.max(INACTIVE_WIDTH, inner - (count - 1) * INACTIVE_WIDTH);\n\n const pillLeft = useRef(new Animated.Value(PAD)).current;\n const pillWidth = useRef(new Animated.Value(INACTIVE_WIDTH)).current;\n const stretch = useRef(new Animated.Value(0)).current;\n const perTab = useRef(new Map<string, TabValues>()).current;\n // The last layout the animated values were set for; a change of width jumps instead of animating.\n const settled = useRef({ width: 0, index: -1 });\n\n const valuesFor = (id: string): TabValues => {\n let values = perTab.get(id);\n if (!values) {\n values = { width: new Animated.Value(INACTIVE_WIDTH), label: new Animated.Value(0) };\n perTab.set(id, values);\n }\n return values;\n };\n\n const ids = tabs.map((tab) => tab.id).join(\"|\");\n\n useEffect(() => {\n if (barWidth === 0) return;\n const jump = reduceMotion || settled.current.width !== barWidth || settled.current.index === -1;\n settled.current = { width: barWidth, index };\n\n const leftTarget = PAD + index * INACTIVE_WIDTH;\n const items = ids.split(\"|\").map((id, i) => ({\n values: valuesFor(id),\n width: i === index ? activeWidth : INACTIVE_WIDTH,\n label: i === index ? 1 : 0,\n }));\n\n if (jump) {\n pillLeft.setValue(leftTarget);\n pillWidth.setValue(activeWidth);\n stretch.setValue(0);\n items.forEach((item) => {\n item.values.width.setValue(item.width);\n item.values.label.setValue(item.label);\n });\n return;\n }\n\n // Layout properties (left, width) cannot use the native driver.\n const spring = (value: Animated.Value, toValue: number) =>\n Animated.spring(value, {\n toValue,\n stiffness: 320,\n damping: 26,\n mass: 1,\n useNativeDriver: false,\n });\n const animation = Animated.parallel([\n spring(pillLeft, leftTarget),\n spring(pillWidth, activeWidth),\n Animated.sequence([\n Animated.timing(stretch, { toValue: 1, duration: 110, useNativeDriver: false }),\n Animated.spring(stretch, {\n toValue: 0,\n stiffness: 260,\n damping: 18,\n mass: 1,\n useNativeDriver: false,\n }),\n ]),\n ...items.map((item) => spring(item.values.width, item.width)),\n ...items.map((item) =>\n Animated.timing(item.values.label, {\n toValue: item.label,\n duration: 180,\n useNativeDriver: NATIVE_DRIVER,\n }),\n ),\n ]);\n animation.start();\n return () => animation.stop();\n // valuesFor only reads refs, and the animated values are stable.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [index, barWidth, activeWidth, ids, reduceMotion]);\n\n const animatedPillWidth = useMemo(\n () =>\n Animated.add(\n pillWidth,\n stretch.interpolate({ inputRange: [0, 1], outputRange: [0, STRETCH] }),\n ),\n [pillWidth, stretch],\n );\n const pillStyle = useMemo(\n () => [\n styles.pill,\n { backgroundColor: palette.pill, left: pillLeft, width: animatedPillWidth },\n ],\n [palette.pill, pillLeft, animatedPillWidth],\n );\n\n return (\n <View\n accessibilityRole=\"tablist\"\n onLayout={(event: LayoutChangeEvent) => setBarWidth(event.nativeEvent.layout.width)}\n style={[styles.bar, { backgroundColor: palette.bar }, style]}\n >\n <Animated.View pointerEvents=\"none\" style={pillStyle} />\n {tabs.map((tab) => (\n <TabItem\n key={tab.id}\n tab={tab}\n selected={tab.id === value}\n values={valuesFor(tab.id)}\n colors={palette}\n onPress={() => onChange(tab.id)}\n />\n ))}\n </View>\n );\n}\n\nfunction TabItem({\n tab,\n selected,\n values,\n colors,\n onPress,\n}: {\n tab: BubbleTab;\n selected: boolean;\n values: TabValues;\n colors: BubbleTabBarColors;\n onPress: () => void;\n}) {\n const color = selected ? colors.active : colors.inactive;\n const boxStyle = useMemo(() => [styles.tab, { width: values.width }], [values.width]);\n const labelStyle = useMemo(() => [styles.label, { opacity: values.label }], [values.label]);\n\n return (\n <Animated.View style={boxStyle}>\n <Pressable\n accessibilityRole=\"tab\"\n accessibilityLabel={tab.label}\n accessibilityState={{ selected }}\n aria-selected={selected}\n onPress={onPress}\n style={({ pressed }) => [styles.press, pressed && styles.pressed]}\n >\n {typeof tab.icon === \"function\" ? tab.icon(color) : tab.icon}\n <Animated.Text numberOfLines={1} style={[labelStyle, { color }]}>\n {tab.label}\n </Animated.Text>\n </Pressable>\n </Animated.View>\n );\n}\n\nconst styles = StyleSheet.create({\n bar: {\n flexDirection: \"row\",\n alignItems: \"center\",\n padding: PAD,\n borderRadius: (TAB_HEIGHT + PAD * 2) / 2,\n userSelect: \"none\",\n boxShadow: \"0 6px 22px rgba(0, 0, 0, 0.14)\",\n },\n pill: {\n position: \"absolute\",\n top: PAD,\n height: TAB_HEIGHT,\n borderRadius: TAB_HEIGHT / 2,\n },\n tab: { height: TAB_HEIGHT, borderRadius: TAB_HEIGHT / 2, overflow: \"hidden\" },\n press: {\n flex: 1,\n flexDirection: \"row\",\n alignItems: \"center\",\n justifyContent: \"center\",\n gap: 8,\n paddingHorizontal: 10,\n },\n pressed: { opacity: 0.7 },\n label: { fontSize: 14, fontWeight: \"700\" },\n});\n"
}
]
}
Loading
Loading