SwiftUI.js
Components

Color

Color is a view that displays a solid color. Color is used to display color swatches, backgrounds, and visual color indicators.

Color is a view that displays a solid color. Color is used to display color swatches, backgrounds, and visual color indicators.

Examples

Basic Usage

Preview unavailable for this example in the static docs build.

Show code
<Color color="#007AFF" style={{ width: '200px', height: '100px' }}></Color>

Color Palette

Preview unavailable for this example in the static docs build.

Show code
<VStack spacing={10}>
      <HStack spacing={10}>
        <Color color="#007AFF" style={{ width: '100px', height: '50px' }} />
        <Text>Blue</Text>
      </HStack>
      <HStack spacing={10}>
        <Color color="#34C759" style={{ width: '100px', height: '50px' }} />
        <Text>Green</Text>
      </HStack>
      <HStack spacing={10}>
        <Color color="#FF9500" style={{ width: '100px', height: '50px' }} />
        <Text>Orange</Text>
      </HStack>
      <HStack spacing={10}>
        <Color color="#FF3B30" style={{ width: '100px', height: '50px' }} />
        <Text>Red</Text>
      </HStack>
    </VStack>

API

PropTypeRequiredDescription
colorstringYesColor value (CSS color string)

Inherits additional props from IBaseComponent.

Overview

Color is a view that displays a solid color. Color is used to display color swatches, backgrounds, and visual color indicators.

SwiftUI Correspondence: Similar to SwiftUI's Color.

Color Palette

Display multiple colors:

Notes

  • Color requires a color prop (hex, rgb, or named color)
  • Color requires explicit dimensions via style prop
  • Color can be used as a background or visual indicator
  • Color supports all CSS color formats
  • Use Color for color swatches and visual indicators

Best Practices

  1. Dimensions: Always provide explicit dimensions
  2. Color formats: Use consistent color formats (hex recommended)
  3. Accessibility: Ensure sufficient contrast when using Color
  4. Visual indicators: Use Color for visual feedback and indicators
  5. Consistency: Use consistent colors throughout your app

On this page