- Accordion
- Attachment
- Avatar
- Badge
- Breadcrumb
- Button
- Button Group
- Card
- Checkbox
- Code Block
- Collapsible
- Dialog
- Dropdown Menu
- Empty
- Field
- Hover Card
- Input
- Input Group
- Input OTP
- Item
- Label
- Marker
- Message
- Number Flow
- Pagination
- Popover
- Progress
- Radio Group
- Select
- Slider
- Sonner
- Spinner
- Switch
- Tooltip
- Separator
- Sheet
- Tabs
- Textarea
- Toggle
- Toggle Group
- Trace
import { View, type ViewProps, type ViewStyle } from "react-native";
import { useThemeColors } from "@/lib/theme";
import { cn } from "@/lib/utils";
export interface SeparatorProps extends Omit<ViewProps, "style"> {
decorative?: boolean;
orientation?: "horizontal" | "vertical";
style?: ViewStyle;
}
function Separator({
decorative = true,
orientation = "horizontal",
className,
style,
...props
}: SeparatorProps) {
const colors = useThemeColors();
const isHorizontal = orientation === "horizontal";
const baseStyle: ViewStyle = {
backgroundColor: colors.border,
flexShrink: 0,
...(isHorizontal
? { height: 1, width: "100%" }
: { alignSelf: "stretch", width: 1 }),
...style,
};
return (
<View
accessibilityRole={decorative ? "none" : undefined}
accessible={!decorative}
className={cn(className)}
style={baseStyle}
{...props}
/>
);
}
export { Separator };A View-based divider. Horizontal by default, vertical with orientation="vertical". When decorative is true (the default) it is hidden from assistive tech. Set decorative={false} when the divider carries structural meaning and should be announced. The color comes from useThemeColors().border, so it tracks light and dark mode without extra configuration.
Installation
$ bunx --bun frakment add separator --expo$ npx frakment add separator --expo$ pnpm dlx frakment add separator --expo$ yarn dlx frakment add separator --expo
Configure NativeWind in your Expo project.
Skip this step if your project already uses NativeWind v5. The project needs a babel.config.js with babel-preset-expo, a metro.config.js wrapped with withNativewind, and a global.css that imports tailwindcss/theme.css, tailwindcss/utilities.css, and nativewind/theme. Import global.css in the root layout.
Copy lib/theme.ts into your project.
The component reads useThemeColors().border. Copy the theme module before the separator.
import { useColorScheme } from "react-native";
export interface ThemeColors {
accent: string;
accentForeground: string;
background: string;
border: string;
destructive: string;
destructiveForeground: string;
destructiveHover: string;
foreground: string;
input: string;
mutedForeground: string;
primary: string;
primaryForeground: string;
primaryHover: string;
secondary: string;
secondaryForeground: string;
secondaryHover: string;
}
const lightColors: ThemeColors = {
accent: "rgba(245, 245, 245, 1)",
accentForeground: "rgba(23, 23, 23, 1)",
background: "rgba(255, 255, 255, 1)",
border: "rgba(229, 229, 229, 1)",
destructive: "rgba(239, 68, 68, 1)",
destructiveForeground: "rgba(255, 255, 255, 1)",
destructiveHover: "rgba(240, 86, 86, 1)",
foreground: "rgba(10, 10, 10, 1)",
input: "rgba(227, 227, 227, 1)",
mutedForeground: "rgba(102, 102, 102, 1)",
primary: "rgba(23, 23, 23, 1)",
primaryForeground: "rgba(250, 250, 250, 1)",
primaryHover: "rgba(46, 46, 46, 1)",
secondary: "rgba(245, 245, 245, 1)",
secondaryForeground: "rgba(23, 23, 23, 1)",
secondaryHover: "rgba(247, 247, 247, 1)",
};
const darkColors: ThemeColors = {
accent: "rgba(64, 64, 64, 1)",
accentForeground: "rgba(250, 250, 250, 1)",
background: "rgba(10, 10, 10, 1)",
border: "rgba(255, 255, 255, 0.1)",
destructive: "rgba(248, 113, 113, 1)",
destructiveForeground: "rgba(255, 255, 255, 1)",
destructiveHover: "rgba(224, 102, 102, 1)",
foreground: "rgba(250, 250, 250, 1)",
input: "rgba(255, 255, 255, 0.15)",
mutedForeground: "rgba(163, 163, 163, 1)",
primary: "rgba(229, 229, 229, 1)",
primaryForeground: "rgba(23, 23, 23, 1)",
primaryHover: "rgba(207, 207, 207, 1)",
secondary: "rgba(38, 38, 38, 1)",
secondaryForeground: "rgba(250, 250, 250, 1)",
secondaryHover: "rgba(33, 33, 33, 1)",
};
export function useThemeColors(): ThemeColors {
const scheme = useColorScheme();
return scheme === "dark" ? darkColors : lightColors;
}Copy the separator into your project.
import { View, type ViewProps, type ViewStyle } from "react-native";
import { useThemeColors } from "@/lib/theme";
import { cn } from "@/lib/utils";
export interface SeparatorProps extends Omit<ViewProps, "style"> {
decorative?: boolean;
orientation?: "horizontal" | "vertical";
style?: ViewStyle;
}
function Separator({
decorative = true,
orientation = "horizontal",
className,
style,
...props
}: SeparatorProps) {
const colors = useThemeColors();
const isHorizontal = orientation === "horizontal";
const baseStyle: ViewStyle = {
backgroundColor: colors.border,
flexShrink: 0,
...(isHorizontal
? { height: 1, width: "100%" }
: { alignSelf: "stretch", width: 1 }),
...style,
};
return (
<View
accessibilityRole={decorative ? "none" : undefined}
accessible={!decorative}
className={cn(className)}
style={baseStyle}
{...props}
/>
);
}
export { Separator };Update the import paths to match your project setup.
Usage
import { Separator } from "@/components/ui/separator";<Separator />;Vertical
import { Text, View } from "react-native";
import { Separator } from "@/components/ui/separator";
export function SeparatorVerticalExample() {
return (
<View className="h-6 flex-row items-center gap-4">
<Text>Docs</Text>
<Separator orientation="vertical" />
<Text>Source</Text>
<Separator orientation="vertical" />
<Text>Design</Text>
</View>
);
}Pass orientation="vertical". The divider sets width to 1px and stretches to fill its parent height. Use it inside a flex-row container.
<View className="h-6 flex-row items-center gap-4">
<Text>Docs</Text>
<Separator orientation="vertical" />
<Text>Source</Text>
</View>Semantic
import { Text, View } from "react-native";
import { Separator } from "@/components/ui/separator";
export function SeparatorDecorativeExample() {
return (
<View className="gap-4">
<Text>Section one</Text>
<Separator decorative={false} />
<Text>Section two</Text>
</View>
);
}Default decorative is true, matching web behavior. Pass decorative={false} to expose the divider to assistive tech. Visual appearance does not change between the two modes.
API Reference
| Prop | Type | Default | Description |
|---|---|---|---|
orientation | horizontalvertical | horizontal | Divider direction. |
decorative | boolean | true | Hides the divider from the accessibility tree when true. |
className | string | — | Additional NativeWind classes. |
style | ViewStyle | — | Inline style override, merged after the computed divider style. |
Accessibility
- Default
decorativeistrue, so the divider is hidden from screen readers. Setdecorative={false}when the divider carries structural meaning. - The divider has no text content. No
accessibilityLabelis needed. - Native does not expose
aria-orientation. Orientation is visual only.
Best Practices
- Prefer the default horizontal divider. Vertical dividers are harder to hit with a finger and rarely needed in touch layouts.
- Do not use a separator as a margin trick. Use
gaporpaddingon the parentViewinstead. - Keep separators one-pixel. The 1px width and height match the web component. Scaling beyond 1px reads as a border, not a divider.
Platform notes
- No
<hr>element. React Native renders the separator as aViewwith a 1px height or width. - No
motionprop. The separator does not animate. Web also does not animate it, so behavior matches. - Color comes from the theme. The web version uses the
borderCSS variable. Native readsuseThemeColors().border, so the resolved color matches across platforms.
Related Components
- Button Group: uses Separator between buttons
- Button: the base button
- Theming: customize colors