For the complete documentation index, see llms.txt. Markdown variants are available by appending .md to any URL or sending an Accept: text/markdown header. An agent skill is available at /.well-known/agent-skills/site-skill.md.
FrakmentFrakment

Button

Displays a button for React Native apps running on Android and iOS via Expo.

button.tsx
import { cva, type VariantProps } from "class-variance-authority";
import * as React from "react";
import {
  Pressable,
  type PressableProps,
  Text,
  type TextStyle,
  type ViewStyle,
} from "react-native";

import { type ThemeColors, useThemeColors } from "@/lib/theme";
import { cn } from "@/lib/utils";

type SizeKey =
  | "xs"
  | "sm"
  | "default"
  | "lg"
  | "icon-xs"
  | "icon-sm"
  | "icon"
  | "icon-lg";

const sizeDim: Record<SizeKey, { height: number; width?: number }> = {
  default: { height: 48 },
  icon: { height: 48, width: 48 },
  "icon-lg": { height: 51, width: 51 },
  "icon-sm": { height: 44, width: 44 },
  "icon-xs": { height: 40, width: 40 },
  lg: { height: 51 },
  sm: { height: 44 },
  xs: { height: 40 },
};

const shadowXs: ViewStyle = {
  boxShadow: "0px 1px 2px 0px rgba(0, 0, 0, 0.05)",
};

const buttonVariants = cva(
  "shrink-0 flex-row items-center justify-center gap-2 rounded-md",
  {
    defaultVariants: { size: "default" },
    variants: {
      size: {
        default: "px-6",
        icon: "p-0",
        "icon-lg": "p-0",
        "icon-sm": "p-0",
        "icon-xs": "p-0",
        lg: "px-8",
        sm: "gap-1.5 px-5",
        xs: "gap-1 px-4",
      },
    },
  }
);

interface VariantStyle {
  base: ViewStyle;
  pressed: ViewStyle;
  textBase: TextStyle;
  textPressed: TextStyle;
}

export type ButtonVariant =
  | "default"
  | "secondary"
  | "outline"
  | "ghost"
  | "destructive"
  | "link";

function getVariantStyle(variant: ButtonVariant, c: ThemeColors): VariantStyle {
  switch (variant) {
    case "secondary":
      return {
        base: { backgroundColor: c.secondary, ...shadowXs },
        pressed: { backgroundColor: c.secondaryHover },
        textBase: { color: c.secondaryForeground },
        textPressed: { color: c.secondaryForeground },
      };
    case "outline":
      return {
        base: {
          backgroundColor: "transparent",
          borderColor: c.border,
          borderWidth: 1,
          ...shadowXs,
        },
        pressed: { backgroundColor: c.accent },
        textBase: { color: c.foreground },
        textPressed: { color: c.accentForeground },
      };
    case "ghost":
      return {
        base: { backgroundColor: "transparent" },
        pressed: { backgroundColor: c.accent },
        textBase: { color: c.foreground },
        textPressed: { color: c.accentForeground },
      };
    case "destructive":
      return {
        base: { backgroundColor: c.destructive, ...shadowXs },
        pressed: { backgroundColor: c.destructiveHover },
        textBase: { color: c.destructiveForeground },
        textPressed: { color: c.destructiveForeground },
      };
    case "link":
      return {
        base: { backgroundColor: "transparent" },
        pressed: {},
        textBase: {
          borderBottomColor: "transparent",
          borderBottomWidth: 1,
          color: c.primary,
          paddingBottom: 1,
        },
        textPressed: {
          borderBottomColor: c.primary,
        },
      };
    default:
      return {
        base: { backgroundColor: c.primary, ...shadowXs },
        pressed: { backgroundColor: c.primaryHover },
        textBase: { color: c.primaryForeground },
        textPressed: { color: c.primaryForeground },
      };
  }
}

export interface ButtonProps
  extends Omit<PressableProps, "children" | "style">,
    VariantProps<typeof buttonVariants> {
  children?: React.ReactNode;
  style?: ViewStyle;
  variant?: ButtonVariant;
}

function Button({
  className,
  variant = "default",
  size,
  children,
  disabled,
  style,
  onPressIn,
  onPressOut,
  ...props
}: ButtonProps) {
  const colors = useThemeColors();
  const [pressed, setPressed] = React.useState(false);
  const vs = getVariantStyle(variant, colors);
  const dim = sizeDim[(size ?? "default") as SizeKey] ?? sizeDim.default;

  const containerStyle: ViewStyle = {
    borderRadius: 8,
    height: dim.height,
    ...(dim.width === undefined ? null : { width: dim.width }),
    ...vs.base,
    ...(pressed && !disabled ? vs.pressed : null),
    ...style,
  };

  const finalTextStyle: TextStyle = {
    ...vs.textBase,
    ...(pressed && !disabled ? vs.textPressed : null),
  };

  return (
    <Pressable
      accessibilityRole="button"
      accessibilityState={{ disabled: !!disabled }}
      className={cn(
        buttonVariants({ size }),
        disabled && "opacity-50",
        className
      )}
      disabled={disabled}
      onPressIn={(e) => {
        setPressed(true);
        onPressIn?.(e);
      }}
      onPressOut={(e) => {
        setPressed(false);
        onPressOut?.(e);
      }}
      style={containerStyle}
      {...props}
    >
      {React.Children.map(children, (child) =>
        typeof child === "string" || typeof child === "number" ? (
          <Text style={finalTextStyle}>{child}</Text>
        ) : (
          child
        )
      )}
    </Pressable>
  );
}

export { Button, buttonVariants };

Buttons for React Native apps that run on Android and iOS via Expo. They share the design tokens and variants of the web Button, with interaction adapted for touch.

Installation

Usage

button.tsx
import { Button } from "@/components/ui/button";
button.tsx
<Button onPress={() => {}}>Click me</Button>

Variants

Default

The primary variant, intended for the most important action on a screen.

button-default.tsx
import { View } from "react-native";

import { Button } from "@/components/ui/button";

export function ButtonDefaultExample() {
  return (
    <View className="gap-2">
      <Button>Button</Button>
    </View>
  );
}

Secondary

Intended for actions of lesser prominence.

button-secondary.tsx
import { View } from "react-native";

import { Button } from "@/components/ui/button";

export function ButtonSecondaryExample() {
  return (
    <View className="gap-2">
      <Button variant="secondary">Secondary</Button>
    </View>
  );
}

Outline

Renders with a border and a transparent background.

button-outline.tsx
import { View } from "react-native";

import { Button } from "@/components/ui/button";

export function ButtonOutlineExample() {
  return (
    <View className="gap-2">
      <Button variant="outline">Outline</Button>
    </View>
  );
}

Ghost

Renders without a border. Background applies only on press.

button-ghost.tsx
import { View } from "react-native";

import { Button } from "@/components/ui/button";

export function ButtonGhostExample() {
  return (
    <View className="gap-2">
      <Button variant="ghost">Ghost</Button>
    </View>
  );
}

Destructive

Intended for destructive or irreversible actions.

button-destructive.tsx
import { View } from "react-native";

import { Button } from "@/components/ui/button";

export function ButtonDestructiveExample() {
  return (
    <View className="gap-2">
      <Button variant="destructive">Destructive</Button>
    </View>
  );
}

Renders as inline text with an underline on press.

button-link.tsx
import { View } from "react-native";

import { Button } from "@/components/ui/button";

export function ButtonLinkExample() {
  return (
    <View className="gap-2">
      <Button variant="link">Link</Button>
    </View>
  );
}

Custom radius

Pass className="rounded-full" to render a pill button.

button-rounded.tsx
import { ArrowUpIcon } from "lucide-react-native";
import { View } from "react-native";

import { Button } from "@/components/ui/button";

export function ButtonRoundedExample() {
  return (
    <View className="flex-row gap-2">
      <Button style={{ borderRadius: 9999 }}>Get Started</Button>
      <Button
        accessibilityLabel="Submit"
        size="icon"
        style={{ borderRadius: 9999 }}
        variant="outline"
      >
        <ArrowUpIcon />
      </Button>
    </View>
  );
}

Size

Use the size prop to control the dimensions of a text button.

The preview above renders at the web size scale. On iOS and Android the component applies the larger values in the table below, sized to meet touch target guidance.

button-size.tsx
import { ArrowUpRightIcon } from "lucide-react-native";
import { View } from "react-native";

import { Button } from "@/components/ui/button";

export function ButtonSizeExample() {
  return (
    <View className="gap-8">
      <View className="flex-row items-start gap-2">
        <Button size="xs" variant="outline">
          Extra Small
        </Button>
        <Button accessibilityLabel="Submit" size="icon-xs" variant="outline">
          <ArrowUpRightIcon />
        </Button>
      </View>
      <View className="flex-row items-start gap-2">
        <Button size="sm" variant="outline">
          Small
        </Button>
        <Button accessibilityLabel="Submit" size="icon-sm" variant="outline">
          <ArrowUpRightIcon />
        </Button>
      </View>
      <View className="flex-row items-start gap-2">
        <Button variant="outline">Default</Button>
        <Button accessibilityLabel="Submit" size="icon" variant="outline">
          <ArrowUpRightIcon />
        </Button>
      </View>
      <View className="flex-row items-start gap-2">
        <Button size="lg" variant="outline">
          Large
        </Button>
        <Button accessibilityLabel="Submit" size="icon-lg" variant="outline">
          <ArrowUpRightIcon />
        </Button>
      </View>
    </View>
  );
}
SizeHeightPadding
xs40dppx-4
sm44dppx-5
default48dppx-6
lg51dppx-8

Icon size

Icon buttons use a separate size system. Each produces a square button sized to fit its icon.

SizeDimensions
icon-xs40×40
icon-sm44×44
icon48×48
icon-lg51×51

Icons & With Icons

Buttons accept an icon next to a label or render as a square icon-only button. Icons are sized by [&_svg]:size-4. Provide the icon as a child of the button.

button.tsx
import { cva, type VariantProps } from "class-variance-authority";
import * as React from "react";
import {
  Pressable,
  type PressableProps,
  Text,
  type TextStyle,
  type ViewStyle,
} from "react-native";

import { type ThemeColors, useThemeColors } from "@/lib/theme";
import { cn } from "@/lib/utils";

type SizeKey =
  | "xs"
  | "sm"
  | "default"
  | "lg"
  | "icon-xs"
  | "icon-sm"
  | "icon"
  | "icon-lg";

const sizeDim: Record<SizeKey, { height: number; width?: number }> = {
  default: { height: 48 },
  icon: { height: 48, width: 48 },
  "icon-lg": { height: 51, width: 51 },
  "icon-sm": { height: 44, width: 44 },
  "icon-xs": { height: 40, width: 40 },
  lg: { height: 51 },
  sm: { height: 44 },
  xs: { height: 40 },
};

const shadowXs: ViewStyle = {
  boxShadow: "0px 1px 2px 0px rgba(0, 0, 0, 0.05)",
};

const buttonVariants = cva(
  "shrink-0 flex-row items-center justify-center gap-2 rounded-md",
  {
    defaultVariants: { size: "default" },
    variants: {
      size: {
        default: "px-6",
        icon: "p-0",
        "icon-lg": "p-0",
        "icon-sm": "p-0",
        "icon-xs": "p-0",
        lg: "px-8",
        sm: "gap-1.5 px-5",
        xs: "gap-1 px-4",
      },
    },
  }
);

interface VariantStyle {
  base: ViewStyle;
  pressed: ViewStyle;
  textBase: TextStyle;
  textPressed: TextStyle;
}

export type ButtonVariant =
  | "default"
  | "secondary"
  | "outline"
  | "ghost"
  | "destructive"
  | "link";

function getVariantStyle(variant: ButtonVariant, c: ThemeColors): VariantStyle {
  switch (variant) {
    case "secondary":
      return {
        base: { backgroundColor: c.secondary, ...shadowXs },
        pressed: { backgroundColor: c.secondaryHover },
        textBase: { color: c.secondaryForeground },
        textPressed: { color: c.secondaryForeground },
      };
    case "outline":
      return {
        base: {
          backgroundColor: "transparent",
          borderColor: c.border,
          borderWidth: 1,
          ...shadowXs,
        },
        pressed: { backgroundColor: c.accent },
        textBase: { color: c.foreground },
        textPressed: { color: c.accentForeground },
      };
    case "ghost":
      return {
        base: { backgroundColor: "transparent" },
        pressed: { backgroundColor: c.accent },
        textBase: { color: c.foreground },
        textPressed: { color: c.accentForeground },
      };
    case "destructive":
      return {
        base: { backgroundColor: c.destructive, ...shadowXs },
        pressed: { backgroundColor: c.destructiveHover },
        textBase: { color: c.destructiveForeground },
        textPressed: { color: c.destructiveForeground },
      };
    case "link":
      return {
        base: { backgroundColor: "transparent" },
        pressed: {},
        textBase: {
          borderBottomColor: "transparent",
          borderBottomWidth: 1,
          color: c.primary,
          paddingBottom: 1,
        },
        textPressed: {
          borderBottomColor: c.primary,
        },
      };
    default:
      return {
        base: { backgroundColor: c.primary, ...shadowXs },
        pressed: { backgroundColor: c.primaryHover },
        textBase: { color: c.primaryForeground },
        textPressed: { color: c.primaryForeground },
      };
  }
}

export interface ButtonProps
  extends Omit<PressableProps, "children" | "style">,
    VariantProps<typeof buttonVariants> {
  children?: React.ReactNode;
  style?: ViewStyle;
  variant?: ButtonVariant;
}

function Button({
  className,
  variant = "default",
  size,
  children,
  disabled,
  style,
  onPressIn,
  onPressOut,
  ...props
}: ButtonProps) {
  const colors = useThemeColors();
  const [pressed, setPressed] = React.useState(false);
  const vs = getVariantStyle(variant, colors);
  const dim = sizeDim[(size ?? "default") as SizeKey] ?? sizeDim.default;

  const containerStyle: ViewStyle = {
    borderRadius: 8,
    height: dim.height,
    ...(dim.width === undefined ? null : { width: dim.width }),
    ...vs.base,
    ...(pressed && !disabled ? vs.pressed : null),
    ...style,
  };

  const finalTextStyle: TextStyle = {
    ...vs.textBase,
    ...(pressed && !disabled ? vs.textPressed : null),
  };

  return (
    <Pressable
      accessibilityRole="button"
      accessibilityState={{ disabled: !!disabled }}
      className={cn(
        buttonVariants({ size }),
        disabled && "opacity-50",
        className
      )}
      disabled={disabled}
      onPressIn={(e) => {
        setPressed(true);
        onPressIn?.(e);
      }}
      onPressOut={(e) => {
        setPressed(false);
        onPressOut?.(e);
      }}
      style={containerStyle}
      {...props}
    >
      {React.Children.map(children, (child) =>
        typeof child === "string" || typeof child === "number" ? (
          <Text style={finalTextStyle}>{child}</Text>
        ) : (
          child
        )
      )}
    </Pressable>
  );
}

export { Button, buttonVariants };

Button Group

For grouped actions, see Button Group. A quick example:

button-group-demo.tsx
import { ArrowLeftIcon, MoreHorizontalIcon } from "lucide-react-native";
import { View } from "react-native";

import { Button } from "@/components/ui/button";
import { ButtonGroup } from "@/components/ui/button-group";

export function ButtonGroupDemoExample() {
  return (
    <View>
      <ButtonGroup>
        <ButtonGroup>
          <Button accessibilityLabel="Go Back" size="icon" variant="outline">
            <ArrowLeftIcon />
          </Button>
        </ButtonGroup>
        <ButtonGroup>
          <Button variant="outline">Archive</Button>
          <Button variant="outline">Report</Button>
        </ButtonGroup>
        <ButtonGroup>
          <Button variant="outline">Snooze</Button>
          <Button
            accessibilityLabel="More Options"
            size="icon"
            variant="outline"
          >
            <MoreHorizontalIcon />
          </Button>
        </ButtonGroup>
      </ButtonGroup>
    </View>
  );
}

API Reference

Button

PropTypeDefaultDescription
variant
defaultsecondaryoutlineghostdestructivelink
defaultThe visual style of the button.
size
xssmdefaultlgicon-xsicon-smiconicon-lg
defaultThe dimensions of the button.
disabledbooleanfalsePrevents interaction. Passed to accessibilityState.disabled.
onPressInfunction—Called when the press starts. Used by the component to track the pressed state.
onPressOutfunction—Called when the press ends.
accessibilityLabelstring—Required for icon-only buttons. Read by screen readers.
classNamestring—Additional NativeWind classes merged with the variant classes.

Accessibility

  • The component sets accessibilityRole="button" on the underlying Pressable.
  • The disabled prop sets accessibilityState={{ disabled: true }}.
  • Provide accessibilityLabel on icon-only buttons.
  • Press feedback uses onPressIn and onPressOut, not hover.

Best Practices

  • Use one primary button per screen.
  • Prefer size="default" or larger for touch-critical actions.
  • Never rely on color alone.
  • Provide accessibilityLabel on icon-only buttons.
  • Reserve destructive for irreversible actions.

Platform notes

  • Press, not hover. Native devices have no hover state. The button renders its pressed state through onPressIn and onPressOut.
  • No anchor mode. React Native has no <a> element. Use the router link from expo-router for navigation, and style it with the exported buttonVariants helper.
  • No motion prop. The web Button exposes a motion prop for CSS transition overrides. Native does not need it because press feedback is instant and driven by the platform.
  • Touch target. Visual size equals tap area. The default and lg sizes meet the 44dp minimum guidance on iOS and the 48dp guidance on Android. For xs and sm, prefer a larger size for touch-critical actions.