Skip to content

Commit

Permalink
feat(website): react-native docs
Browse files Browse the repository at this point in the history
  • Loading branch information
igorwessel committed May 3, 2023
1 parent 993ea1c commit 6106d90
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions website/pages/docs/getting-started/react-native.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
section: Getting Started
title: React Native
slug: /docs/react-native/
order: 8
---

# React Native

<carbon-ad />

xstyled can be used with React Native in the same way and with the same import just as styled-components did.

### Diferrences between browser and react-native

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.

### Exposes components with and without utility props

The philosophy of xstyled is to use x.\* as much as possible.

But we provide all react native components in `styled` without utility props, and components with utility props using the `Box` suffix.

```js
import styled from '@xstyled/styled-components/native'

const WithoutUtility = styled.View``
const WithUtility = styled.ViewBox`` // it's the same as using x.View
```

## Setup

Learn how to setup with react-native.

### Use `ThemeProvider` from `@xstyled/styled-components/native`

```js
// App.js
import { defaultTheme, ThemeProvider } from '@xstyled/styled-components/native'

const theme = {
...defaultTheme,
// Customize your theme here
}

export default function App() {
return <ThemeProvider theme={theme}></ThemeProvider>
}
```

### Write your first component

```js
import { x } from '@xstyled/styled-components/native'

function Button(props) {
return <x.Button bg="blue-500" title="Test" {...props} />
}
```

0 comments on commit 6106d90

Please sign in to comment.