Skip to main content
Themed components are the foundation of GymApp’s UI. They automatically adapt their colors based on the system color scheme, providing a consistent experience across light and dark modes.

ThemedText

A text component that automatically applies theme-aware colors and includes predefined typography variants.

Props

type
'default' | 'title' | 'defaultSemiBold' | 'subtitle' | 'link'
default:"'default'"
Typography variant to apply:
  • default: Regular body text (16px, line height 24)
  • title: Large heading (32px, bold)
  • defaultSemiBold: Semi-bold body text (16px, weight 600)
  • subtitle: Section heading (20px, bold)
  • link: Link styling (16px, blue color)
lightColor
string
Override text color in light mode (e.g., "#000000")
darkColor
string
Override text color in dark mode (e.g., "#FFFFFF")
style
StyleProp<TextStyle>
Additional React Native style props
...rest
TextProps
All standard React Native Text props are supported (onPress, numberOfLines, etc.)

Usage Examples

import { ThemedText } from '@/components/themed-text';

export default function MyScreen() {
  return (
    <>
      <ThemedText>Regular text that adapts to theme</ThemedText>
      <ThemedText type="title">Welcome!</ThemedText>
      <ThemedText type="subtitle">Step 1: Try it</ThemedText>
      <ThemedText type="defaultSemiBold">app/(tabs)/index.tsx</ThemedText>
    </>
  );
}

Typography Variants

The component includes these predefined variants:
VariantFont SizeLine HeightWeightUse Case
default16px24px400Body text
defaultSemiBold16px24px600Emphasized text
title32px32pxboldPage titles
subtitle20px-boldSection headings
link16px30px-Hyperlinks

ThemedView

A view container that automatically applies theme-aware background colors.

Props

lightColor
string
Override background color in light mode (e.g., "#FFFFFF")
darkColor
string
Override background color in dark mode (e.g., "#000000")
style
StyleProp<ViewStyle>
Additional React Native style props
...otherProps
ViewProps
All standard React Native View props are supported (onLayout, testID, etc.)

Usage Examples

import { ThemedView } from '@/components/themed-view';
import { ThemedText } from '@/components/themed-text';

export default function MyScreen() {
  return (
    <ThemedView style={{ padding: 16 }}>
      <ThemedText>Content goes here</ThemedText>
    </ThemedView>
  );
}

Implementation Details

Both components use the useThemeColor hook to automatically resolve colors:
components/themed-text.tsx
export type ThemedTextProps = TextProps & {
  lightColor?: string;
  darkColor?: string;
  type?: 'default' | 'title' | 'defaultSemiBold' | 'subtitle' | 'link';
};

export function ThemedText({
  style,
  lightColor,
  darkColor,
  type = 'default',
  ...rest
}: ThemedTextProps) {
  const color = useThemeColor({ light: lightColor, dark: darkColor }, 'text');

  return (
    <Text
      style={[
        { color },
        type === 'default' ? styles.default : undefined,
        type === 'title' ? styles.title : undefined,
        type === 'defaultSemiBold' ? styles.defaultSemiBold : undefined,
        type === 'subtitle' ? styles.subtitle : undefined,
        type === 'link' ? styles.link : undefined,
        style,
      ]}
      {...rest}
    />
  );
}
components/themed-view.tsx
export type ThemedViewProps = ViewProps & {
  lightColor?: string;
  darkColor?: string;
};

export function ThemedView({ style, lightColor, darkColor, ...otherProps }: ThemedViewProps) {
  const backgroundColor = useThemeColor({ light: lightColor, dark: darkColor }, 'background');

  return <View style={[{ backgroundColor }, style]} {...otherProps} />;
}

Best Practices

Always use ThemedText and ThemedView instead of the standard Text and View components to ensure your UI adapts properly to theme changes.
Only use lightColor and darkColor props when you need specific colors for branding or emphasis. Let the theme system handle most color decisions.
Use appropriate text types for hierarchy: title for page headers, subtitle for sections, defaultSemiBold for emphasis, and default for body text.
Use the style prop for layout and spacing (padding, margin, flexbox), while letting the component handle colors.

UI Components

Explore specialized components

Theming

Learn about the theming system

Build docs developers (and LLMs) love