Skip to content

Commit ccdc8df

Browse files
committed
feat(website): react-native docs
1 parent 29181a5 commit ccdc8df

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
section: Getting Started
3+
title: React Native
4+
slug: /docs/react-native/
5+
order: 8
6+
---
7+
8+
# React Native
9+
10+
<carbon-ad />
11+
12+
xstyled can be used with React Native in the same way and with the same import just as styled-components did.
13+
14+
### Diferrences between browser and react-native
15+
16+
It works in the "same way" as the browser's xstyled but some utility properties have been removed because react-native doesn't support it, for example: grid, transformations.
17+
18+
### Exposes components with and without utility props
19+
20+
The philosophy of xstyled is to use x.\* as much as possible.
21+
22+
But we provide all react native components in `styled` without utility props, and components with utility props using the `Box` suffix.
23+
24+
```js
25+
import styled from '@xstyled/styled-components/native'
26+
27+
const WithoutUtility = styled.View``
28+
const WithUtility = styled.ViewBox`` // it's the same as using x.View
29+
```
30+
31+
## Setup
32+
33+
Learn how to setup with react-native.
34+
35+
### Use `ThemeProvider` from `@xstyled/styled-components/native`
36+
37+
```js
38+
// App.js
39+
import { defaultTheme, ThemeProvider } from '@xstyled/styled-components/native'
40+
41+
const theme = {
42+
...defaultTheme,
43+
// Customize your theme here
44+
}
45+
46+
export default function App() {
47+
return <ThemeProvider theme={theme}></ThemeProvider>
48+
}
49+
```
50+
51+
### Write your first component
52+
53+
```js
54+
import { x } from '@xstyled/styled-components/native'
55+
56+
function Button(props) {
57+
return <x.Button bg="blue-500" title="Test" {...props} />
58+
}
59+
```

0 commit comments

Comments
 (0)