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
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ When working in this repository, you MUST follow these rules:
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).
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`.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ For Cursor, Windsurf or VS Code setup, see [`packages/mcp`](packages/mcp). The d
| **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.

## Documentation

Expand Down
7 changes: 7 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ const renamed = require("./component-redirects.json");

/** @type {import('next').NextConfig} */
const nextConfig = {
// Native (React Native) component demos render on the site through react-native-web.
transpilePackages: ["react-native-web"],
webpack: (config) => {
config.resolve.alias = { ...config.resolve.alias, "react-native$": "react-native-web" };
config.resolve.extensions = [".web.js", ".web.ts", ".web.tsx", ...config.resolve.extensions];
return config;
},
images: {
remotePatterns: [
{
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"next-themes": "^0.4.6",
"react": "^18",
"react-dom": "^18",
"react-native-web": "^0.21.4",
"remark-gfm": "^4.0.1",
"shaders": "4.0.4",
"shiki": "^4.0.2",
Expand All @@ -64,6 +65,7 @@
"prettier": "^3.9.9",
"prettier-plugin-tailwindcss": "^0.6.14",
"prisma": "^6.19.3",
"react-native": "0.88.1",
"tailwindcss": "^3.4.1",
"ts-node": "^10.9.2",
"tsx": "^4.21.0",
Expand Down
4 changes: 3 additions & 1 deletion packages/mcp/src/catalogue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export interface CatalogueComponent {
name: string;
title: string;
category: string;
/** "native" components are React Native (Expo); everything else is a web component. */
platform?: "web" | "native";
description: string;
dependencies: string[];
}
Expand Down Expand Up @@ -97,7 +99,7 @@ export function fallbackMarkdown(
"",
entry.description,
"",
`Category: ${entry.category}. Docs: ${origin}/components/${entry.name}`,
`Category: ${entry.category}. ${entry.platform === "native" ? "Platform: React Native (Expo). " : ""}Docs: ${origin}/components/${entry.name}`,
"",
"## Installation",
"",
Expand Down
1,487 changes: 1,453 additions & 34 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions public/registry/curved-carousel-hero.json

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions public/registry/fan-menu.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "fan-menu",
"title": "Fan Menu",
"category": "Native",
"type": "components:ui",
"platform": "native",
"added": "2026-10-30",
"dependencies": [],
"files": [
{
"path": "registry/fan-menu.tsx",
"content": "import { useEffect, useRef, useState, type ReactNode } from \"react\";\nimport {\n AccessibilityInfo,\n Animated,\n Platform,\n Pressable,\n StyleSheet,\n View,\n type StyleProp,\n type ViewStyle,\n} from \"react-native\";\n\nconst NATIVE_DRIVER = Platform.OS !== \"web\";\nconst ITEM_SIZE = 46;\n\nexport interface FanMenuItem {\n /** Spoken label, since the button shows only its icon. */\n label: string;\n icon: ReactNode;\n onPress: () => void;\n}\n\nexport interface FanMenuColors {\n button: string;\n bar: string;\n item: string;\n}\n\nconst DEFAULT_COLORS: FanMenuColors = {\n button: \"#4f46e5\",\n bar: \"#ffffff\",\n item: \"#ffffff\",\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 FanMenuProps {\n items: FanMenuItem[];\n /** Spoken label of the main button. */\n label?: string;\n /** Diameter of the main button. */\n size?: number;\n /** Distance from the main button to each item. */\n radius?: number;\n /** Where the fan starts, in degrees: 0 is right, 90 down, 180 left, 270 up. */\n startAngle?: number;\n /** Where the fan ends, in degrees. */\n endAngle?: number;\n colors?: Partial<FanMenuColors>;\n style?: StyleProp<ViewStyle>;\n}\n\n/**\n * A floating button that fans its actions out along an arc. The items spring out one after another,\n * the plus turns into a cross, and picking an item folds the fan away. Place it with `style`; the\n * items are positioned from the button, so keep room for the arc on that side.\n */\nexport function FanMenu({\n items,\n label = \"Actions\",\n size = 58,\n radius = 104,\n startAngle = 180,\n endAngle = 270,\n colors,\n style,\n}: FanMenuProps) {\n const palette = { ...DEFAULT_COLORS, ...colors };\n const reduceMotion = useReduceMotion();\n const [open, setOpen] = useState(false);\n const progress = useRef(items.map(() => new Animated.Value(0))).current;\n const turn = useRef(new Animated.Value(0)).current;\n\n useEffect(() => {\n const target = open ? 1 : 0;\n if (reduceMotion) {\n progress.forEach((value) => value.setValue(target));\n turn.setValue(target);\n return;\n }\n Animated.parallel([\n Animated.spring(turn, {\n toValue: target,\n stiffness: 300,\n damping: 22,\n mass: 1,\n useNativeDriver: NATIVE_DRIVER,\n }),\n Animated.stagger(\n 45,\n (open ? progress : [...progress].reverse()).map((value) =>\n Animated.spring(value, {\n toValue: target,\n stiffness: 260,\n damping: 17,\n mass: 1,\n useNativeDriver: NATIVE_DRIVER,\n }),\n ),\n ),\n ]).start();\n }, [open, reduceMotion, progress, turn]);\n\n const spread = items.length > 1 ? (endAngle - startAngle) / (items.length - 1) : 0;\n const first = items.length > 1 ? startAngle : (startAngle + endAngle) / 2;\n\n return (\n <View style={[{ width: size, height: size }, style]}>\n {items.map((item, i) => {\n const radians = ((first + spread * i) * Math.PI) / 180;\n const value = progress[i];\n return (\n <Animated.View\n key={item.label}\n pointerEvents={open ? \"auto\" : \"none\"}\n style={[\n styles.item,\n {\n width: ITEM_SIZE,\n height: ITEM_SIZE,\n borderRadius: ITEM_SIZE / 2,\n left: (size - ITEM_SIZE) / 2,\n top: (size - ITEM_SIZE) / 2,\n backgroundColor: palette.item,\n opacity: value.interpolate({ inputRange: [0, 0.4, 1], outputRange: [0, 1, 1] }),\n transform: [\n {\n translateX: value.interpolate({\n inputRange: [0, 1],\n outputRange: [0, Math.cos(radians) * radius],\n }),\n },\n {\n translateY: value.interpolate({\n inputRange: [0, 1],\n outputRange: [0, Math.sin(radians) * radius],\n }),\n },\n { scale: value.interpolate({ inputRange: [0, 1], outputRange: [0.4, 1] }) },\n ],\n },\n ]}\n >\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel={item.label}\n onPress={() => {\n setOpen(false);\n item.onPress();\n }}\n style={({ pressed }) => [styles.itemPress, pressed && styles.pressed]}\n >\n {item.icon}\n </Pressable>\n </Animated.View>\n );\n })}\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel={label}\n accessibilityState={{ expanded: open }}\n aria-expanded={open}\n onPress={() => setOpen((current) => !current)}\n style={({ pressed }) => [\n styles.button,\n { width: size, height: size, borderRadius: size / 2, backgroundColor: palette.button },\n pressed && styles.pressed,\n ]}\n >\n <Animated.View\n style={{\n width: size * 0.34,\n height: size * 0.34,\n transform: [\n { rotate: turn.interpolate({ inputRange: [0, 1], outputRange: [\"0deg\", \"135deg\"] }) },\n ],\n }}\n >\n <View style={[styles.bar, styles.barAcross, { backgroundColor: palette.bar }]} />\n <View style={[styles.bar, styles.barDown, { backgroundColor: palette.bar }]} />\n </Animated.View>\n </Pressable>\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n item: {\n position: \"absolute\",\n boxShadow: \"0 4px 14px rgba(0, 0, 0, 0.2)\",\n },\n itemPress: { flex: 1, alignItems: \"center\", justifyContent: \"center\", borderRadius: 999 },\n button: {\n alignItems: \"center\",\n justifyContent: \"center\",\n boxShadow: \"0 6px 18px rgba(0, 0, 0, 0.25)\",\n },\n pressed: { opacity: 0.85 },\n bar: { position: \"absolute\", borderRadius: 2 },\n barAcross: { left: 0, right: 0, top: \"50%\", height: 3, marginTop: -1.5 },\n barDown: { top: 0, bottom: 0, left: \"50%\", width: 3, marginLeft: -1.5 },\n});\n"
}
]
}
15 changes: 15 additions & 0 deletions public/registry/glide-segments.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "glide-segments",
"title": "Glide Segments",
"category": "Native",
"type": "components:ui",
"platform": "native",
"added": "2026-10-30",
"dependencies": [],
"files": [
{
"path": "registry/glide-segments.tsx",
"content": "import { useEffect, useRef, useState } 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 PADDING = 3;\n\nexport interface GlideSegmentsOption {\n value: string;\n label: string;\n}\n\nexport interface GlideSegmentsColors {\n track: string;\n thumb: string;\n text: string;\n selectedText: string;\n}\n\nconst DEFAULT_COLORS: GlideSegmentsColors = {\n track: \"#e5e7eb\",\n thumb: \"#ffffff\",\n text: \"#6b7280\",\n selectedText: \"#111827\",\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 GlideSegmentsProps {\n options: GlideSegmentsOption[];\n value: string;\n onChange: (value: string) => void;\n /** Height of the control. */\n height?: number;\n colors?: Partial<GlideSegmentsColors>;\n style?: StyleProp<ViewStyle>;\n}\n\n/**\n * A segmented control whose thumb glides between options on a spring and stretches slightly as it\n * travels. Segments share the width equally, take the full touch target, and read as tabs to\n * screen readers.\n */\nexport function GlideSegments({\n options,\n value,\n onChange,\n height = 40,\n colors,\n style,\n}: GlideSegmentsProps) {\n const palette = { ...DEFAULT_COLORS, ...colors };\n const reduceMotion = useReduceMotion();\n const [width, setWidth] = useState(0);\n const x = useRef(new Animated.Value(0)).current;\n const stretch = useRef(new Animated.Value(1)).current;\n\n const index = Math.max(\n 0,\n options.findIndex((option) => option.value === value),\n );\n const segment = options.length > 0 ? (width - PADDING * 2) / options.length : 0;\n\n useEffect(() => {\n if (segment === 0) return;\n const target = index * segment;\n if (reduceMotion) {\n x.setValue(target);\n return;\n }\n Animated.parallel([\n Animated.spring(x, {\n toValue: target,\n stiffness: 420,\n damping: 32,\n mass: 1,\n useNativeDriver: NATIVE_DRIVER,\n }),\n Animated.sequence([\n Animated.timing(stretch, { toValue: 1.12, duration: 110, useNativeDriver: NATIVE_DRIVER }),\n Animated.spring(stretch, {\n toValue: 1,\n stiffness: 300,\n damping: 20,\n mass: 1,\n useNativeDriver: NATIVE_DRIVER,\n }),\n ]),\n ]).start();\n }, [index, segment, reduceMotion, x, stretch]);\n\n return (\n <View\n accessibilityRole=\"tablist\"\n onLayout={(event: LayoutChangeEvent) => setWidth(event.nativeEvent.layout.width)}\n style={[\n styles.track,\n { height, borderRadius: height / 2, backgroundColor: palette.track },\n style,\n ]}\n >\n {segment > 0 ? (\n <Animated.View\n pointerEvents=\"none\"\n style={[\n styles.thumb,\n {\n width: segment,\n borderRadius: (height - PADDING * 2) / 2,\n backgroundColor: palette.thumb,\n transform: [{ translateX: x }, { scaleX: stretch }],\n },\n ]}\n />\n ) : null}\n {options.map((option) => {\n const selected = option.value === value;\n return (\n <Pressable\n key={option.value}\n accessibilityRole=\"tab\"\n accessibilityState={{ selected }}\n aria-selected={selected}\n onPress={() => onChange(option.value)}\n style={styles.segment}\n >\n <Text\n numberOfLines={1}\n style={[styles.label, { color: selected ? palette.selectedText : palette.text }]}\n >\n {option.label}\n </Text>\n </Pressable>\n );\n })}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n track: { flexDirection: \"row\", padding: PADDING, userSelect: \"none\" },\n thumb: {\n position: \"absolute\",\n top: PADDING,\n bottom: PADDING,\n left: PADDING,\n boxShadow: \"0 1px 3px rgba(0, 0, 0, 0.16)\",\n },\n segment: { flex: 1, alignItems: \"center\", justifyContent: \"center\", paddingHorizontal: 8 },\n label: { fontSize: 14, fontWeight: \"600\" },\n});\n"
}
]
}
Loading
Loading