Skip to content
  • Introduction
    nativecn is shadcn for Expo apps: Components you copy into your app and own, built so AI agents can build and verify whole mobile apps.
  • Installation
    Create a new Expo app with nativecn, or add nativecn to an existing one.
  • components.json
    The project file that records your Preset, Structure, aliases and agents.
  • CLI
    Every nativecn-cli command and flag: init, create, add, agents and mcp.
  • Changelog
    What changed in each nativecn release.
  • Theming
    Tokens, Colour Roles, Scale, Scheme, createStyles and fonts.
  • Presets & Styles
    Style, Base Colour, Accent Colour, Radius and fonts: chosen once, baked into your code.
  • Folder structure
    Flat and feature Structures, Destinations and the placement rule.
  • AI agents
    Rules, Skills, the nativecn MCP server, the Plugin and the Visual QA Loop.
  • Alert
    Alert, AlertTitle and AlertDescription: an inline message with Variants (default, destructive, success, warning, info), each with a default icon.
  • Avatar
    Round user image (expo-image) with fallback initials, in sizes sm, md and lg.
  • Badge
    Small status label with Variants default, secondary, outline, destructive, success and warning.
  • Button
    Button with Variants (primary, secondary, outline, ghost, destructive, link), Sizes, an icon slot, loading and status; icon-only requires aria-label.
  • Card
    Card surface with CardHeader, CardTitle, CardDescription, CardContent and CardFooter; onPress makes the whole card pressable.
  • Checkbox
    Checkbox with an optional label, controlled or uncontrolled, an indeterminate (mixed) state and a haptic tick.
  • Chip
    Chip (plain, toggle or removable, with an optional icon) and ChipGroup (single or multiple choice on the SelectionGroup Primitive), with a haptic tick.
  • Container
    Wraps a Screen: safe-area edges, scrolling, keyboard avoidance, Token padding and a max content width.
  • Drawer
    Drawer panel content for Expo Router's drawer (expo-router/drawer): DrawerContent, DrawerHeader, DrawerSection, DrawerItem (label, icon, href, badge; active from the current route) and DrawerFooter.
  • Empty State
    What a Screen or list shows when there is nothing to show yet: an icon, a title, a description and an action.
  • FormField
    Lays out a control with its Label, description and error, and links them for screen readers ("Email, text field, Enter a valid email").
  • Icon
    Every glyph: a Lucide icon at a Token size in a Colour Role, decorative unless labelled.
  • Input
    Single-line text field with Sizes, a leading icon, error/success status, a focus ring and an automatic Show/Hide password toggle.
  • InputOTP
    One-time code field: one hidden input drives N cells; numeric keyboard, SMS/Keychain autofill, paste, onComplete, error/success status and secure.
  • Label
    A field's visible label in the label type Variant, with a required marker read as "required".
  • List
    Settings-style rows: ListSection, ListSectionHeader, ListSectionFooter and ListItem (title, description, icon, trailing, chevron, destructive, onPress); FlashList-safe.
  • Progress
    A horizontal progress bar: a value 0–100 that animates, or indeterminate; role progressbar with its value.
  • RadioGroup
    RadioGroup and RadioGroupItem: a single choice from a list on the SelectionGroup Primitive, vertical or horizontal, with a haptic tick.
  • SchemeSwitcher
    Theme switcher / dark mode toggle: System, Light and Dark as SegmentedTabs, or one icon button cycling through them. Calls setScheme, which persists the choice.
  • SearchField
    Search box with a search icon, an automatic clear (×) button, a loading spinner and onSubmit from the keyboard's Search key.
  • SegmentedTabs
    In-screen tabs (not navigation): segmented or underline Variants, an animated indicator, and only the selected tab's content rendered.
  • Separator
    A hairline divider, horizontal or vertical, decorative by default.
  • Skeleton
    A placeholder shape shown while content loads; pulses unless Reduce Motion is on, hidden from screen readers.
  • Slider
    Pick a number in a range by dragging or tapping (Gesture Handler + Reanimated), snapped to steps with a haptic tick; adjustable for screen readers.
  • Spinner
    An indeterminate loading indicator in a Colour Role, announced as busy; still under Reduce Motion.
  • Switch
    A themed on/off Switch, identical on iOS and Android, with an optional label, a thumb that slides (instant under Reduce Motion) and a haptic tick.
  • TabNavigation
    The bottom tab bar: the custom tabBar of an Expo Router JS Tabs Layout, with classic and floating Variants, per-tab icons and badges from Tabs.Screen options.
  • Text
    All text: the type ramp as Variants, text Colour Roles, alignment and the font-scaling switch.
  • Textarea
    Multi-line text field that grows from minRows to maxRows, with a character counter when maxLength is set.
  • Toast
    Sonner-style Toasts: a <Toaster /> in the root Layout and toast(), toast.success/error/info/warning/dismiss. At most 3 stacked, 4s auto-dismiss, swipe away, announced, above native modals.
  • Profile header + grouped sections
    Drawer panel with a profile header (avatar, name, email, plan Badge), labelled sections (Main, Workspace, Support) and Log out pinned in the footer.
  • SaaS workspace
    Drawer panel for a SaaS workspace: logo and name with a close button, an Accent Colour onboarding item with a 5 Steps Badge, main items, a bottom group (Notifications with a count, Settings, Docs, Help) and a footer with a team switcher and the user's avatar.
  • Cover header
    Drawer panel with a dark cover (large avatar, name, View profile, a bell with a count, an overflow button and a round + action), icon items active in Accent Colour text, a divider and text-only secondary items.
  • Classic centred
    A centred sign-in Screen: logo, email and password, Forgot password, an "or" divider, then Apple and Google, and a Sign up link.
  • Social-first hero
    A social-first sign-in Screen: a dark brand hero (logo, headline, subtitle, centred) above a panel where Apple and Google lead and "Continue with email" reveals the email form.
  • Email-first, two steps
    An email-first sign-in Screen in two steps: the email, then the password, with "Email me a code instead" switching to a 6-digit code (InputOTP). Lucide chevron-left Back buttons.
  • Classic single form
    A classic sign-up Screen on one scroll: Apple and Google on top, "or", then name, email and password, a terms Checkbox with Terms and Privacy Policy links, Create account, and a Sign in link.
  • Step-by-step wizard
    A sign-up wizard, one question per step under a Progress bar: email, name, password, then a 6-digit code (InputOTP). Lucide chevron-left Back buttons; the Continue button rides above the keyboard.
  • Social-first + verify
    A brand-led, passwordless sign-up Screen: the logo and headline centred above Apple and Google; "Sign up with email" reveals the email field, and Send code moves on to a 6-digit code (InputOTP).
  • announce
    Reliable screen-reader announcements on iOS and Android (Button and Input status, Toast, error, success and warning Alerts).
  • FocusChain
    Automatic Next/Done between fields in on-screen order; Done submits the form.
  • FormField context
    Links a field to its label, description and error for screen readers; passes status, disabled and required down.
  • Keyboard
    KeyboardProvider setup, a scroll view that keeps the focused field above the keyboard, and a footer that keeps a form's main button above it.
  • Portal
    Renders content above every Screen (above native modals on iOS), layered and safe-area aware.
  • Pressable
    Pressed look from a Style Slot, tap area extended to 48, no handlers while disabled or loading, optional haptics, role and aria-* states.
  • SelectionGroup
    Single or multiple choice within a group, with radio, tab or checkbox roles and selected states.
  • useControllableState
    One implementation of controlled and uncontrolled values for form controls.
  • useMotion
    Enter/exit animations and timing/spring configs from the motion Tokens; instant when Reduce Motion is on.
  • Theme
    Tokens, Scale, Colour Roles, ThemeProvider, createStyles and the navigation theme.

Button

Button with Variants (primary, secondary, outline, ghost, destructive, link), Sizes, an icon slot, loading and status; icon-only requires aria-label.

View as Markdown
Componentcore
Style

Light

Dark

Your app is ready.

Inter body text, Inter headings.

smmdlgxl
you@example.com
Continue
Default Preset a0: Vega, neutral, neutral accent, default radius, Inter.Change Preset

Installation

$npx nativecn-cli@latest add button

Also installs: theme, pressable, text, icon, spinner, announce.

Packages: lucide-react-native@^1.51.0, react-native-svg, react-native-reanimated, react-native-worklets.

Usage

Button demo

Every Variant and Size, an icon, icon-only, loading, status and disabled.

import { ArrowRight, Trash } from "lucide-react-native";
import { useState } from "react";
import { View } from "react-native";

import { Button } from "@/components/button";
import { createStyles } from "@/theme";

/** Variants, Sizes, an icon, icon-only, loading and status. */
export default function ButtonDemo() {
  const styles = useStyles();
  const [saving, setSaving] = useState(false);
  const [saved, setSaved] = useState(false);

  const save = () => {
    setSaving(true);
    setTimeout(() => {
      setSaving(false);
      setSaved(true);
    }, 800);
  };

  return (
    <View style={styles.stack}>
      <View style={styles.row}>
        <Button label="Primary" />
        <Button label="Secondary" variant="secondary" />
        <Button label="Outline" variant="outline" />
      </View>
      <View style={styles.row}>
        <Button label="Ghost" variant="ghost" />
        <Button label="Delete" variant="destructive" />
        <Button label="Learn more" variant="link" />
      </View>
      <View style={styles.row}>
        <Button label="Small" size="sm" />
        <Button label="Large" size="lg" />
        {/* Icon-only: aria-label is required. */}
        <Button icon={Trash} variant="outline" aria-label="Delete draft" />
      </View>
      <Button label="Continue" icon={ArrowRight} iconPosition="end" />
      {/* The screen sets and clears status; the Button never resets it. */}
      <Button
        label={saved ? "Saved" : "Save"}
        loading={saving}
        status={saved ? "success" : undefined}
        onPress={save}
      />
      <Button label="Disabled" disabled />
    </View>
  );
}

const useStyles = createStyles((t) => ({
  stack: { gap: t.spacing[3] },
  row: { flexDirection: "row", flexWrap: "wrap", alignItems: "center", gap: t.spacing[2] },
}));

Props

PropType and description
...PressablePropsPressable Primitive props pass through (onPress, onLongPress, haptic, testID, ...)
labelstring: the visible text and accessible name (required unless icon-only)
iconLucideIcon: shown in the icon slot
iconPosition"start" (default) | "end": where the icon slot sits
variant"primary" (default) | "secondary" | "outline" | "ghost" | "destructive" | "link"
size"sm" | "md" (default) | "lg"
loadingboolean: a Spinner takes the icon slot, the label stays, presses are blocked, announced busy
status"error" | "success": a status icon in the icon slot, announced once; the screen clears it
disabledboolean: dimmed, presses blocked, announced disabled
aria-labelstring: required for icon-only Buttons (icon and no label)
styleViewStyle, layout only (e.g. full width), merged last

Variants

  • variant: primary, secondary, outline, ghost, destructive, link
  • size: sm, md, lg
  • status: error, success

Accessibility

  • role button; the label is the accessible name.
  • Icon-only Buttons are typed to require aria-label.
  • The tap area is extended to 48 high, and to 48 wide for icon-only Buttons.
  • disabled is announced as disabled and loading as busy; no press handler runs in either state.
  • A new status is announced once ("Save: error"); the loading Spinner stays silent because the Button is already busy.
  • The label uses the button text Variant, which caps the OS font scale at 1.5× when font scaling is on.

Notes

Built on the Pressable Primitive: the pressed look comes from the button.pressed Style Slot. Precedence: disabled > loading > status. Make a Button full width with style={{ alignSelf: 'stretch' }}; there is no fullWidth prop. Buttons give no haptic tick by default.

Source

The Vega Style's code, exactly as add copies it into your app.

{components}/button.tsx

import { Check, CircleAlert, type LucideIcon } from "lucide-react-native";
import { useEffect, useRef } from "react";
import type { StyleProp, ViewStyle } from "react-native";

import { Icon, type IconSize } from "@/components/icon";
import { Pressable, type PressableProps } from "@/components/primitives/pressable";
import { Spinner } from "@/components/spinner";
import { Text, type TextColor } from "@/components/text";
import { createStyles, type ColorRole } from "@/theme";
import { announce } from "@/utils/announce";

/** Each Variant's Colour Roles: fill, content and (optional) border. */
const variants = {
  primary: { background: "primary", foreground: "primaryForeground" },
  secondary: { background: "secondary", foreground: "secondaryForeground" },
  outline: { background: "background", foreground: "foreground", border: "border" },
  ghost: { foreground: "foreground" },
  destructive: { background: "destructive", foreground: "destructiveForeground" },
  link: { foreground: "primary", underline: true },
} as const satisfies Record<
  string,
  { background?: ColorRole; foreground: TextColor; border?: ColorRole; underline?: boolean }
>;

export type ButtonVariant = keyof typeof variants;
export type ButtonSize = "sm" | "md" | "lg";
export type ButtonStatus = "error" | "success";

const statusIcons = { error: CircleAlert, success: Check } as const;
const iconSizes = { sm: "sm", md: "md", lg: "lg" } as const satisfies Record<ButtonSize, IconSize>;

type ButtonBaseProps = Omit<
  PressableProps,
  "children" | "style" | "size" | "pressedStyle" | "aria-label"
> & {
  /** Placement of the icon slot (icon, spinner or status icon) next to the label (default `start`). */
  iconPosition?: "start" | "end";
  /** Default `primary`. */
  variant?: ButtonVariant;
  /** Default `md`. */
  size?: ButtonSize;
  /** A spinner takes the icon slot, the label stays, presses are blocked and it is announced busy. */
  loading?: boolean;
  /** Shows an error or success icon in the icon slot and announces it. The screen clears it. */
  status?: ButtonStatus;
  /** Layout only (e.g. full width), merged last onto the root. */
  style?: StyleProp<ViewStyle>;
};

type LabelledButtonProps = {
  /** The visible text, which is also the accessible name. */
  label: string;
  /** A Lucide icon component shown in the icon slot. */
  icon?: LucideIcon;
  "aria-label"?: string;
};

type IconOnlyButtonProps = {
  label?: undefined;
  icon: LucideIcon;
  /** Required for an icon-only Button: it is the only accessible name. */
  "aria-label": string;
};

/** A Button has a `label`, or is icon-only with an `icon` and a required `aria-label`. */
export type ButtonProps = ButtonBaseProps & (LabelledButtonProps | IconOnlyButtonProps);

const useStyles = createStyles((t) => {
  const md = {
    height: t.controlHeight.md,
    borderRadius: t.radius.md,
    paddingHorizontal: t.spacing[4],
    gap: t.spacing[2],
  };
  const sm = {
    height: t.controlHeight.sm,
    paddingHorizontal: t.spacing[3],
    gap: t.scaleValue(6),
  };
  const lg = {
    height: t.controlHeight.lg,
    paddingHorizontal: t.spacing[6],
    gap: t.spacing[2],
  };
  return {
    root: {
      ...md,
      flexDirection: "row",
      alignItems: "center",
      justifyContent: "center",
      borderCurve: "continuous",
      borderWidth: t.borderWidth.default,
      borderColor: "transparent",
    },
    sm,
    md: {},
    lg,
    iconOnlySm: { width: sm.height, paddingHorizontal: 0 },
    iconOnlyMd: { width: md.height, paddingHorizontal: 0 },
    iconOnlyLg: { width: lg.height, paddingHorizontal: 0 },
    label: { ...t.type.button },
    underline: { textDecorationLine: "underline" },
    pressed: { filter: [{ brightness: 0.88 }] },
    disabled: { opacity: t.opacity.disabled },
  };
});

const useVariantStyles = createStyles((t) => ({
  primary: { backgroundColor: t.colors.primary },
  secondary: { backgroundColor: t.colors.secondary },
  outline: { backgroundColor: t.colors.background, borderColor: t.colors.border },
  ghost: { backgroundColor: "transparent" },
  destructive: { backgroundColor: t.colors.destructive },
  link: { backgroundColor: "transparent" },
}));

const iconOnlyStyle = { sm: "iconOnlySm", md: "iconOnlyMd", lg: "iconOnlyLg" } as const;

/**
 * The app's Button. Variants and Sizes map to Tokens and Style Slots; built on the Pressable
 * Primitive (pressed look from the `button.pressed` Slot, tap area extended to 48, no press
 * while disabled or loading). Precedence: `disabled` > `loading` > `status`.
 */
export function Button({
  label,
  icon,
  iconPosition = "start",
  variant = "primary",
  size = "md",
  disabled = false,
  loading = false,
  status,
  style,
  ...props
}: ButtonProps) {
  const styles = useStyles();
  const variantStyles = useVariantStyles();
  const v: { foreground: TextColor; underline?: boolean } = variants[variant];

  const isLoading = !disabled && loading;
  const shownStatus = disabled || loading ? undefined : status;
  const iconOnly = label == null;

  // Announce a new status once; the visible icon alone is not enough for screen readers.
  const announced = useRef<ButtonStatus | undefined>(undefined);
  useEffect(() => {
    if (shownStatus && shownStatus !== announced.current) {
      announce(label ? `${label}: ${shownStatus}` : shownStatus);
    }
    announced.current = shownStatus;
  }, [shownStatus, label]);

  // Known before layout, so the tap area reaches 48 from the first frame.
  const height = (size === "md" ? styles.root : styles[size]).height;

  const iconColor = v.foreground;
  const slotIcon = isLoading ? (
    // The Button itself is announced busy, so the Spinner stays silent.
    <Spinner size={iconSizes[size]} color={iconColor} aria-hidden />
  ) : shownStatus ? (
    <Icon icon={statusIcons[shownStatus]} size={iconSizes[size]} color={iconColor} />
  ) : icon ? (
    <Icon icon={icon} size={iconSizes[size]} color={iconColor} />
  ) : null;

  return (
    <Pressable
      disabled={disabled}
      loading={isLoading}
      size={{ height, width: iconOnly ? height : undefined }}
      pressedStyle={styles.pressed}
      style={[
        styles.root,
        styles[size],
        variantStyles[variant],
        iconOnly ? styles[iconOnlyStyle[size]] : null,
        disabled ? styles.disabled : null,
        style,
      ]}
      {...props}
    >
      {iconPosition === "start" ? slotIcon : null}
      {label != null ? (
        <Text
          variant="button"
          color={v.foreground}
          numberOfLines={1}
          style={[styles.label, v.underline ? styles.underline : null]}
        >
          {label}
        </Text>
      ) : null}
      {iconPosition === "end" ? slotIcon : null}
    </Pressable>
  );
}