Gathering detailed insights and metrics for @audira/carbon-react-native
Gathering detailed insights and metrics for @audira/carbon-react-native
Gathering detailed insights and metrics for @audira/carbon-react-native
Gathering detailed insights and metrics for @audira/carbon-react-native
npm install @audira/carbon-react-native
Typescript
Module System
Node Version
NPM Version
TypeScript (93.96%)
JavaScript (4.39%)
Kotlin (0.79%)
Ruby (0.48%)
Swift (0.38%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
326 Commits
1 Watchers
2 Branches
1 Contributors
Updated on May 17, 2025
Latest Version
0.0.1-alpha.17
Package Id
@audira/carbon-react-native@0.0.1-alpha.17
Unpacked Size
4.15 MB
Size
1.47 MB
File Count
2,713
NPM Version
10.9.2
Node Version
22.15.0
Published on
May 17, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
This library is completely rewritten and not intended to be the replacement of the official carbon-react-native
⚠️ It is still in development
Build React Native apps with component and shared patterns using Carbon.
Documentation available with docusaurus project on this repository under docs directory. It's not completed yet, even the library, but it will be documented enough, as soon as the library is ready to use.
You can install this repository dependencies with pnpm install
, and start the docusaurus with npm run start
command in the docs directory, or you can also start the React Native CLI example app with npm run start
in the example directory.
This library is just a pure JavaScript usage in React Native and only depends on the primitive React Native components with react-native-reanimated and react-native-svg. It should compatible on all platforms available that can be built with React Native, but i cannot sure that. For the web only, Carbon React is already there and do its best and solve a lot of accessibility feature.
Install the library to your project
with npm
npm install @audira/carbon-react-native @audira/carbon-react-native-elements
pnpm
pnpm install @audira/carbon-react-native @audira/carbon-react-native-elements
yarn
yarn add @audira/carbon-react-native @audira/carbon-react-native-elements
Install these dependencies on your React Native project, (skip one of these library if already installed)
Install the IBM Plex Sans
font to your project with react-native-asset. Update your react-native.config.js
file (create it on your root project directory if doesn't exist)
1module.exports = { 2 assets: [ 3 './node_modules/@audira/carbon-react-native/assets/fonts/', 4 ], 5}
Then, run npx react-native-asset
to link the fonts
This library depends on React Context to use the color tokens correctly based on the current color scheme. You have to wrap your whole React App once with <CarbonReactNative>
1// Somewhere like in your App.tsx file 2import { 3 CarbonReactNative, 4} from '@audira/carbon-react-native' 5 6export default function App() { 7 return ( 8 <CarbonReactNative> 9 { /* the rest of your react */ } 10 </CarbonReactNative> 11 ) 12}
Not all components are available yet, but you can test one of this library's component that are available
1import { 2 Button, 3} from '@audira/carbon-react-native' 4 5import AddIcon from '@carbon/icons/es/add/20' 6 7export default function YourReactComponent() { 8 return ( 9 <Button.PrimaryDanger 10 text="Press this" 11 icon={ AddIcon } 12 /> 13 ) 14}
While this library is still in development and there is no documentation available, this library is written in TypeScript. You can just refer to this components source for a while.
You can use current color token based on what color scheme which are Gray 10
and Gray 100
. It is available by using ThemeContext
that are already provided by CarbonReactNative
.
1import { 2 useContext, 3} from 'react' 4 5import { 6 Text, 7 ThemeContext, 8} from '@audira/carbon-react-native' 9 10export default function YourReactComponent() { 11 const themeContext = useContext(ThemeContext) 12 13 return ( 14 <Text type="label_01" style={{ color: themeContext.color.support_error }}> 15 React Native 16 </Text> 17 ) 18}
All components are also made by using ThemeContext
by the way. All members of the color is same as the official color tokens here, but it is using underscore (_) instead of dash (-).
Instead of inline styles, you can also use color token from this library's StyleSheet
. This is also recommended way to support React Native for Web's to generate CSS
1import { 2 useContext, 3} from 'react' 4 5import { 6 StyleSheet, 7 Text, 8 ThemeContext, 9} from '@audira/carbon-react-native' 10 11export default function YourReactComponent() { 12 /** 13 * Keep this to make `style` prop reactive on color scheme change 14 */ 15 StyleSheet.use() 16 17 return ( 18 <Text type="label_01" style={ style.linkText }> 19 React Native 20 </Text> 21 ) 22} 23 24const style = StyleSheet.create({ 25 linkText: { 26 color: StyleSheet.color.link_primary, 27 }, 28})
You can use elements are available which are Color
, Spacing
, Typography
, and Motion
. Refer to this source
1import { 2 StyleSheet, 3 View, 4} from 'react-native' 5 6import { 7 Spacing, 8} from '@audira/carbon-react-native-elements' 9 10export default function YourReactComponent() { 11 return ( 12 <View style={ style.container }> 13 { /* other contents */ } 14 </View> 15 ) 16} 17 18const style = StyleSheet.create({ 19 container: { 20 paddingHorizontal: Spacing.spacing_05, 21 }, 22})
colorScheme
: gray_10
| gray_100
This UI library will solve what color scheme on your project natively, with this map
gray_10
gray_100
If you want override the colorScheme, as an example you only want to use the gray_100
color scheme (dark mode only), you fill the prop with gray_100
value
1import { 2 CarbonReactNative, 3} from '@audira/carbon-react-native' 4 5export default function App() { 6 return ( 7 <CarbonReactNative colorScheme="gray_100"> 8 { /* the rest of your react */ } 9 </CarbonReactNative> 10 ) 11}
Not recommended to override the color token that are made by Carbon, but you can still override it or just change one of the color token members.
:warning: Be aware of this. All components are made also get the impact of color token change
1import { 2 CarbonReactNative, 3 ColorConstant, 4} from '@audira/carbon-react-native' 5 6export default function App() { 7 return ( 8 <CarbonReactNative 9 overrideColor={{ 10 ...ColorConstant.Tokens.GRAY_100, 11 button_primary: '#9021e5', // as an example, change button_primary from blue originally to purple 12 }} 13 > 14 { /* the rest of your react */ } 15 </CarbonReactNative> 16 ) 17}
Caveat, if you fill this prop, colorScheme
will means nothing, since it depends on whatever your logic here.
Another example, you can still follow the light and dark theme by using gray_10
and gray_100
and extends it
1import { 2 useColorScheme, 3} from 'react-native' 4 5import { 6 CarbonReactNative, 7 ColorHelper, 8 type ThemeType, 9} from '@audira/carbon-react-native' 10 11export default function App() { 12 const 13 nativeColorScheme = 14 useColorScheme(), 15 16 colorScheme = 17 ColorHelper.getColorScheme(nativeColorScheme) 18 19 return ( 20 <CarbonReactNative 21 overrideColor={{ 22 ...ColorHelper.getColorToken(colorScheme), 23 button_primary: customColorToken[colorScheme].button_primary, 24 }} 25 > 26 { /* the rest of your react */ } 27 </CarbonReactNative> 28 ) 29} 30 31const customColorToken: Record<ThemeType.ColorScheme, { button_primary: string }> = { 32 gray_10: { 33 button_primary: '#9021e5', 34 }, 35 gray_100: { 36 button_primary: '#a421e5' 37 }, 38}
No vulnerabilities found.
No security vulnerabilities found.