Configs2026年5月19日·1 分钟阅读

NativeBase — Universal Component Library for React Native and Web

An accessible, utility-first component library for building consistent UIs across React Native, Android, iOS, and Web from a single codebase.

Agent 就绪

这个资产可以被 Agent 直接读取和安装

TokRepo 同时提供通用 CLI 命令、安装契约、metadata JSON、按适配器生成的安装计划和原始内容链接,方便 Agent 判断适配度、风险和下一步动作。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
NativeBase Overview
通用 CLI 安装命令
npx tokrepo install 1dd56f65-535c-11f1-9bc6-00163e2b0d79

Introduction

NativeBase is a component library that lets developers build UIs for React Native and Web from a single codebase. It provides utility-style props inspired by Tailwind CSS and Chakra UI, making it easy to style components inline without separate stylesheets. The library ships with 40+ accessible, themeable components.

What NativeBase Does

  • Provides 40+ pre-built components (Box, Stack, Button, Input, Modal, etc.)
  • Supports utility-style props for spacing, colors, layout, and typography
  • Renders on iOS, Android, and Web from the same component code
  • Ships a theme system with customizable tokens (colors, sizes, fonts)
  • Includes accessibility attributes by default on all interactive components

Architecture Overview

NativeBase wraps React Native primitives and adds a styling layer that resolves utility props into platform-specific styles at render time. The NativeBaseProvider at the app root injects a theme context. Components read from this context and merge theme defaults with inline utility props. The resolution engine handles responsive breakpoints and color mode (light/dark) automatically.

Self-Hosting & Configuration

  • Install native-base and required peer dependencies
  • Wrap the app root with <NativeBaseProvider>
  • Customize the theme using extendTheme() for colors, fonts, and component defaults
  • Use useColorMode() to toggle between light and dark themes
  • Integrate with Expo or bare React Native projects

Key Features

  • Utility-first prop API similar to Chakra UI
  • Responsive props with breakpoint arrays: w={['100%', '50%', '33%']}
  • Dark mode support with useColorMode and _dark pseudo props
  • Full TypeScript support with autocomplete for utility props
  • Composable layout primitives: Box, HStack, VStack, Center, ZStack

Comparison with Similar Tools

  • React Native Elements — simpler API but no utility-style props
  • Tamagui — compiler-optimized, targets both web and native with better perf
  • React Native Paper — Material Design focused, less flexible theming
  • Chakra UI — web-only, NativeBase brings a similar API to native
  • Gluestack UI — successor project with headless primitives approach

FAQ

Q: Does NativeBase work with Expo? A: Yes, it supports Expo managed and bare workflows. SVG peer dependency may need Expo-compatible installation.

Q: How do I add custom fonts? A: Extend the theme with fontConfig and fonts keys, then use them via the fontFamily prop.

Q: Can I use NativeBase on web without React Native Web? A: No, NativeBase relies on React Native Web for browser rendering.

Q: What is the relationship between NativeBase and Gluestack? A: The NativeBase team created Gluestack UI as a next-generation alternative with headless components.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产