Top Related Projects
Customizable Icons for React Native with support for image source and full styling.
Mobile-first, accessible components for React Native & Web to build consistent UI across Android, iOS and Web.
Material Design for React Native (Android & iOS)
Cross-Platform React Native UI Toolkit
UI Components Library for React Native
:boom: React Native UI Library based on Eva Design System :new_moon_with_face::sparkles:Dark Mode
Quick Overview
React Native Material Kit (RNMK) is a set of UI components and customizable theme provider for React Native applications. It aims to implement Google's Material Design principles in React Native, offering a wide range of pre-built components that can be easily customized to fit your app's design needs.
Pros
- Comprehensive set of Material Design components for React Native
- Highly customizable with a flexible theming system
- TypeScript support for improved development experience
- Active community and regular updates
Cons
- Some components may not be fully optimized for performance
- Documentation could be more detailed and up-to-date
- Limited support for complex animations
- May require additional setup for certain platforms or React Native versions
Code Examples
- Creating a simple button:
import React from 'react';
import { Button } from 'react-native-material-kit';
const MyButton = () => (
<Button title="Click me" onPress={() => console.log('Button pressed')} />
);
- Using a customized text input:
import React from 'react';
import { TextInput } from 'react-native-material-kit';
const MyTextInput = () => (
<TextInput
label="Username"
placeholder="Enter your username"
helperText="Must be at least 3 characters"
variant="outlined"
/>
);
- Implementing a themed component:
import React from 'react';
import { ThemeProvider, useTheme, Text } from 'react-native-material-kit';
const MyThemedComponent = () => {
const { colors } = useTheme();
return <Text style={{ color: colors.primary }}>Themed Text</Text>;
};
const App = () => (
<ThemeProvider>
<MyThemedComponent />
</ThemeProvider>
);
Getting Started
To start using React Native Material Kit in your project:
-
Install the package:
npm install react-native-material-kit
-
Import and use components in your React Native app:
import React from 'react'; import { View } from 'react-native'; import { Button, ThemeProvider } from 'react-native-material-kit'; const App = () => ( <ThemeProvider> <View> <Button title="Hello, Material UI!" onPress={() => {}} /> </View> </ThemeProvider> ); export default App;
-
Customize the theme (optional):
import { createTheme, ThemeProvider } from 'react-native-material-kit'; const theme = createTheme({ palette: { primary: { main: '#1976d2', }, }, }); const App = () => ( <ThemeProvider theme={theme}> {/* Your app components */} </ThemeProvider> );
Competitor Comparisons
Customizable Icons for React Native with support for image source and full styling.
Pros of react-native-vector-icons
- Extensive icon library with multiple icon sets (FontAwesome, Material Icons, etc.)
- Easy customization of icon color, size, and style
- Supports both iOS and Android platforms seamlessly
Cons of react-native-vector-icons
- Limited to icon-based components, not a full UI kit
- Requires additional setup for custom icon sets
- May increase app size due to multiple icon sets
Code Comparison
react-native-vector-icons:
import Icon from 'react-native-vector-icons/FontAwesome';
<Icon name="rocket" size={30} color="#900" />
react-native-material-kit:
import { Button } from 'react-native-material-kit';
<Button text="BUTTON" />
Summary
react-native-vector-icons is a versatile icon library for React Native, offering a wide range of icon sets and easy customization. It's ideal for projects requiring diverse icon options but lacks full UI components.
react-native-material-kit provides a comprehensive Material Design UI kit for React Native, including buttons, cards, and other UI elements. It offers a cohesive design system but may have a steeper learning curve and less flexibility in icon choices.
Choose react-native-vector-icons for icon-focused needs and react-native-material-kit for a complete Material Design implementation in React Native projects.
Mobile-first, accessible components for React Native & Web to build consistent UI across Android, iOS and Web.
Pros of NativeBase
- More comprehensive component library with a wider range of UI elements
- Better documentation and community support
- Customizable theme system for consistent styling across the app
Cons of NativeBase
- Larger bundle size due to the extensive component library
- Steeper learning curve for beginners
- Some components may have performance issues in complex layouts
Code Comparison
NativeBase:
import { Box, Text, Button } from 'native-base';
const MyComponent = () => (
<Box>
<Text>Hello, NativeBase!</Text>
<Button>Click me</Button>
</Box>
);
react-native-material-kit:
import { MKButton, MKColor } from 'react-native-material-kit';
const MyComponent = () => (
<View>
<Text>Hello, Material Kit!</Text>
<MKButton backgroundColor={MKColor.Teal}>
Click me
</MKButton>
</View>
);
NativeBase offers a more React-like component structure with built-in styling, while react-native-material-kit provides lower-level components that require more manual styling. NativeBase's approach may be more intuitive for React developers, but react-native-material-kit offers more granular control over Material Design elements.
Material Design for React Native (Android & iOS)
Pros of react-native-paper
- More comprehensive component library with a wider range of UI elements
- Better documentation and examples, making it easier for developers to implement
- Regular updates and active maintenance from the Callstack team
Cons of react-native-paper
- Larger bundle size due to the extensive component library
- Some components may have a steeper learning curve for beginners
Code Comparison
react-native-material-kit:
import { MKButton } from 'react-native-material-kit';
<MKButton
backgroundColor={MKColor.Teal}
shadowRadius={2}
shadowOffset={{width:0, height:2}}
shadowOpacity={.7}
shadowColor="black"
onPress={() => console.log('Hi!')}
>
I'm a button
</MKButton>
react-native-paper:
import { Button } from 'react-native-paper';
<Button
mode="contained"
onPress={() => console.log('Pressed')}
style={{ marginTop: 16 }}
>
Press me
</Button>
The code comparison shows that react-native-paper offers a more straightforward and concise implementation for basic components like buttons. However, react-native-material-kit provides more granular control over styling properties, which may be preferred by some developers for custom designs.
Cross-Platform React Native UI Toolkit
Pros of React Native Elements
- More comprehensive component library with a wider range of UI elements
- Better documentation and community support
- More frequent updates and active maintenance
Cons of React Native Elements
- Larger package size, which may impact app performance
- Less focus on Material Design principles compared to React Native Material Kit
Code Comparison
React Native Elements:
import { Button } from 'react-native-elements';
<Button
title="Click me"
buttonStyle={{ backgroundColor: 'blue' }}
onPress={() => console.log('Button pressed')}
/>
React Native Material Kit:
import { Button } from 'react-native-material-kit';
<Button
text="Click me"
style={{ backgroundColor: 'blue' }}
onPress={() => console.log('Button pressed')}
/>
Both libraries offer similar functionality for basic components like buttons. However, React Native Elements provides more customization options out of the box, while React Native Material Kit focuses on adhering to Material Design guidelines.
React Native Elements is generally more suitable for projects requiring a wide range of customizable UI components, while React Native Material Kit is better for applications specifically targeting Material Design aesthetics. The choice between the two depends on the project's specific requirements and design goals.
UI Components Library for React Native
Pros of react-native-ui-lib
- More comprehensive component library with a wider range of UI elements
- Active development and regular updates
- Better documentation and examples
Cons of react-native-ui-lib
- Larger package size due to more components
- Steeper learning curve for beginners
- May require more customization for specific design needs
Code Comparison
react-native-material-kit:
import { MKButton } from 'react-native-material-kit';
<MKButton
backgroundColor={MKColor.Teal}
shadowRadius={2}
shadowOffset={{width:0, height:2}}
shadowOpacity={.7}
shadowColor="black"
onPress={() => console.log('Hi!')}
>
I'm a button
</MKButton>
react-native-ui-lib:
import { Button } from 'react-native-ui-lib';
<Button
label="I'm a button"
backgroundColor="#00AAAF"
enableShadow
onPress={() => console.log('Hi!')}
/>
The code comparison shows that react-native-ui-lib offers a more concise and straightforward approach to creating UI components, while react-native-material-kit provides more granular control over styling properties. Both libraries aim to simplify the process of creating visually appealing and functional UI elements in React Native applications.
:boom: React Native UI Library based on Eva Design System :new_moon_with_face::sparkles:Dark Mode
Pros of React Native UI Kitten
- More comprehensive UI component library with a wider range of pre-built elements
- Supports theming and customization out of the box, allowing for easy style changes
- Active development and maintenance, with regular updates and bug fixes
Cons of React Native UI Kitten
- Steeper learning curve due to its more complex architecture and custom components
- Larger bundle size, which may impact app performance on lower-end devices
- Less adherence to Material Design guidelines compared to React Native Material Kit
Code Comparison
React Native UI Kitten:
import { Button } from '@ui-kitten/components';
<Button>BUTTON</Button>
React Native Material Kit:
import { Button } from 'react-native-material-kit';
<Button text="BUTTON" />
Both libraries offer simple ways to create buttons, but React Native UI Kitten uses a more modern, functional approach with child components, while React Native Material Kit uses props for text content.
React Native UI Kitten provides a more extensive set of customization options and theming capabilities, making it suitable for projects requiring a unique visual identity. However, React Native Material Kit may be preferable for developers seeking a straightforward implementation of Material Design principles in their React Native applications.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
A set of UI components, in the purpose of introducing Material Design to apps built with React Native, quickly and painlessly.
Getting Started
First, cd
to your RN project directory, and install RNMK through rnpm . If you don't have rnpm, you can install RNMK from npm with the command npm i -S react-native-material-kit
and link it manually (see below).
NOTICE:
react-native-material-kit >= 0.4.0 only supports react-native >= 0.40.0
react-native-material-kit < 0.4.0 only supports react-native < 0.40.0
iOS
-
React Native < 0.29 (Using rnpm)
rnpm install react-native-material-kit
-
React Native >= 0.29
npm install -S react-native-material-kit
react-native link react-native-material-kit
Manually
- Add
node_modules/react-native-material-kit/iOS/RCTMaterialKit.xcodeproj
to your xcode project, usually under theLibraries
group - Add
libRCTMaterialKit.a
(fromProducts
underRCTMaterialKit.xcodeproj
) to build target'sLinked Frameworks and Libraries
list
Option: Using CocoaPods
Assuming you have CocoaPods installed, create a PodFile
like this in your app's project directory. You can leave out the modules you don't need.
xcodeproj 'path/to/YourProject.xcodeproj/'
pod 'React', :subspecs => ['Core', 'RCTText', 'RCTWebSocket'], :path => 'node_modules/react-native'
pod 'react-native-material-kit', :path => 'node_modules/react-native-material-kit'
post_install do |installer|
target = installer.pods_project.targets.select{|t| 'React' == t.name}.first
phase = target.new_shell_script_build_phase('Run Script')
phase.shell_script = "if nc -w 5 -z localhost 8081 ; then\n if ! curl -s \"http://localhost:8081/status\" | grep -q \"packager-status:running\" ; then\n echo \"Port 8081 already in use, packager is either not running or not running correctly\"\n exit 2\n fi\nelse\n open $SRCROOT/../node_modules/react-native/packager/launchPackager.command || echo \"Can't start packager automatically\"\nfi"
end
Now run pod install
. This will create an Xcode workspace containing all necessary native files, including react-native-material-kit. From now on open YourProject.xcworkspace
instead of YourProject.xcodeproject
in Xcode. Because React Native's iOS code is now pulled in via CocoaPods, you also need to remove the React
, RCTImage
, etc. subprojects from your app's Xcode project, in case they were added previously.
Android
-
React Native < 0.29 (Using rnpm)
rnpm install react-native-material-kit
-
React Native >= 0.29
npm install -S react-native-material-kit
react-native link react-native-material-kit
Manually
- JDK 7+ is required
- Add the following snippet to your
android/settings.gradle
:
include ':RNMaterialKit'
project(':RNMaterialKit').projectDir = file('../node_modules/react-native-material-kit/android')
- Declare the dependency in your
android/app/build.gradle
dependencies {
...
compile project(':RNMaterialKit')
}
- Import
com.github.xinthink.rnmk.ReactMaterialKitPackage
and register it in yourMainActivity
(or equivalent, RN >= 0.32 MainApplication.java):
@Override
protected List<ReactPackage> getPackages() {
return Arrays.asList(
new MainReactPackage(),
new ReactMaterialKitPackage()
);
}
Manual Installation Issues
If you experience any trouble manually installing react-native-material-kit
on Android,
you should be able to safely skip it.
Finally, you're good to go, feel free to require react-native-material-kit
in your JS files.
Have fun! :metal:
Resources
- Release Notes
- Refer to the Annotated Source as API docs
- Source code of Demo app
- For contributors, please refer to How to debug local RNMK module
- Chat about bugs/features on Gitter
Components
Buttons
Apply Material Design Buttons with a few lines of code using predefined builders, which comply with the Material Design Lite default theme.
// colored button with default theme (configurable)
const ColoredRaisedButton = MKButton.coloredButton()
.withText('BUTTON')
.withOnPress(() => {
console.log("Hi, it's a colored button!");
})
.build();
...
<ColoredRaisedButton />
And you can definitely build customized buttons from scratch.
with builder:
const CustomButton = new MKButton.Builder()
.withBackgroundColor(MKColor.Teal)
.withShadowRadius(2)
.withShadowOffset({width:0, height:2})
.withShadowOpacity(.7)
.withShadowColor('black')
.withOnPress(() => {
console.log('hi, raised button!');
})
.withTextStyle({
color: 'white',
fontWeight: 'bold',
})
.withText('RAISED BUTTON')
.build();
...
<CustomButton />
the jsx equivalent:
<MKButton
backgroundColor={MKColor.Teal}
shadowRadius={2}
shadowOffset={{width:0, height:2}}
shadowOpacity={.7}
shadowColor="black"
onPress={() => {
console.log('hi, raised button!');
}}
>
<Text pointerEvents="none"
style={{color: 'white', fontWeight: 'bold',}}>
RAISED BUTTON
</Text>
</MKButton>
ð props reference and example code
Why builders? See the âBuilder vs. configuration objectâ discussion.
Cards
Apply Card Style
with only few styles !.
import {
getTheme,
...
} from 'react-native-material-kit';
const theme = getTheme();
<View style={theme.cardStyle}>
<Image source={{uri : base64Icon}} style={theme.cardImageStyle} />
<Text style={theme.cardTitleStyle}>Welcome</Text>
<Text style={theme.cardContentStyle}>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Mauris sagittis pellentesque lacus eleifend lacinia...
</Text>
<View style={theme.cardMenuStyle}>{menu}</View>
<Text style={theme.cardActionStyle}>My Action</Text>
</View>
ð example code
Loading
MDL Loading components.
Progress bar
<mdl.Progress
style={styles.progress}
progress={0.2}
/>
ð props reference and example code
Spinner
<mdl.Spinner />
ð props reference and example code
Sliders
MDL Slider components.
<mdl.Slider style={styles.slider} />
â¦
const SliderWithValue = mdl.Slider.slider()
.withStyle(styles.slider)
.withMin(10)
.withMax(100)
.build();
â¦
<SliderWithValue
ref="sliderWithValue"
onChange={(curValue) => this.setState({curValue})}
/>
ð props reference and example code
Range Slider
<mdl.RangeSlider style={styles.slider} />
â¦
const SliderWithRange = mdl.RangeSlider.slider()
.withStyle(styles.slider)
.withMin(10)
.withMax(100)
.withMinValue(30)
.withMaxValue(50)
.build();
â¦
<SliderWithRange
ref="sliderWithRange"
onChange={(curValue) => this.setState({
min: curValue.min,
max: curValue.max,
})
}
onConfirm={(curValue) => {
console.log("Slider drag ended");
console.log(curValue);
}}
/>
ð props reference and example code
Text Fields
Built-in textfields, which comply with Material Design Lite.
// textfield with default theme (configurable)
const Textfield = MKTextField.textfield()
.withPlaceholder('Text...')
.withStyle(styles.textfield)
.build();
...
<Textfield />
Customizing textfields through builder:
const CustomTextfield = mdl.Textfield.textfield()
.withPlaceholder("Text...")
.withStyle(styles.textfield)
.withTintColor(MKColor.Lime)
.withTextInputStyle({color: MKColor.Orange})
.build();
...
<CustomTextfield />
the jsx equivalent:
<Textfield
tintColor={MKColor.Lime}
textInputStyle={{color: MKColor.Orange}}
placeholder=âTextâ¦â
style={styles.textfield}
/>
ð props reference and example code
Toggles
Icon toggle
<MKIconToggle
checked={true}
onCheckedChange={this._onIconChecked}
onPress={this._onIconClicked}
>
<Text
pointerEvents="none"
style={styles.toggleTextOff}>Off</Text>
<Text state_checked={true}
pointerEvents="none"
style={[styles.toggleText, styles.toggleTextOn]}>On</Text>
</MKIconToggle>
The two Text
tags here, similar to State List in Android development, which can give you the flexibility to decide what content and how it is shown for each state of the toggle. For example, you can use react-native-icons here, or any other sophisticated contents.
ð props reference and example code
Switch
<mdl.Switch
style={styles.appleSwitch}
onColor="rgba(255,152,0,.3)"
thumbOnColor={MKColor.Orange}
rippleColor="rgba(255,152,0,.2)"
onPress={() => console.log('orange switch pressed')}
onCheckedChange={(e) => console.log('orange switch checked', e)}
/>
ð props reference and example code
Checkbox
<MKCheckbox
checked={true}
/>
You can customize the styles by changing the global theme, which affects all checkboxes across the whole app.
setTheme({checkboxStyle: {
fillColor: MKColor.Teal,
borderOnColor: MKColor.Teal,
borderOffColor: MKColor.Teal,
rippleColor: `rgba(${MKColor.RGBTeal},.15)`,
}});
ð props reference and example code
Radio button
constructor() {
super();
this.radioGroup = new MKRadioButton.Group();
}
...
<MKRadioButton
checked={true}
group={this.radioGroup}
/>
You can customize the styles by changing the global theme, which affects all radio buttons across the whole app.
setTheme({radioStyle: {
fillColor: `rgba(${MKColor.RGBTeal},.8)`,
borderOnColor: `rgba(${MKColor.RGBTeal},.6)`,
borderOffColor: `rgba(${MKColor.RGBTeal},.3)`,
rippleColor: `rgba(${MKColor.RGBTeal},.15)`,
}});
ð props reference and example code
Top Related Projects
Customizable Icons for React Native with support for image source and full styling.
Mobile-first, accessible components for React Native & Web to build consistent UI across Android, iOS and Web.
Material Design for React Native (Android & iOS)
Cross-Platform React Native UI Toolkit
UI Components Library for React Native
:boom: React Native UI Library based on Eva Design System :new_moon_with_face::sparkles:Dark Mode
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot