Skip to content

Commit

Permalink
Add MUI system theming snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
mj12albert committed Apr 2, 2023
1 parent 8f7cf4d commit 33e6381
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions docs/data/base/getting-started/quickstart/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@

`@mui/base` is completely standalone – run one of the following commands to add Base UI to your React project:

### npm
### With npm

```sh
npm install @mui/base
```

### yarn
### With yarn

```sh
yarn add @mui/base
```

### pnpm
### With pnpm

```sh
pnpm add @mui/base
Expand Down Expand Up @@ -146,7 +146,33 @@ Here's a complete demo of the same button styled with Tailwind instead:

MUI System's core utility is a [`styled` function](/system/styled/) that is equivalent to emotion's or styled-components' styled(). Interpolations or arguments that are functions called by `styled` receive the `theme` from an upper `ThemeProvider`.

Most of the demos and examples in the Base UI documentation are styled with MUI system in this way.
```tsx
import * as React from 'react';
import { ThemeProvider } from '@emotion/react';
import ButtonUnstyled from '@mui/base/ButtonUnstyled';

const theme = {
colors: {
primary: 'green'
}
}

const GithubButton = styled(ButtonUnstyled)(
({ theme }) => `
background-color: ${theme.colors.primary/* => 'green' */};
`,
);

render(
<ThemeProvider theme={theme}>
<GithubButton>
Create Repository
</GithubButton>
</ThemeProvider>
)
```

Most of the demos and examples in the Base UI documentation are styled with MUI system in this way. You can inspect the `theme` object used on this site in your browser console, or explore the default structure [here](/material-ui/customization/default-theme/).

#### Styling `ButtonUnstyled` with MUI System

Expand Down Expand Up @@ -200,7 +226,7 @@ export default function App() {

#### Using the `sx` prop

MUI System supports the [`sx` prop](/system/getting-started/the-sx-prop/), which provides a quick way to apply ad-hoc styles using theme-aware values directly to any component created with `styled`.
MUI System supports the [`sx` prop](/system/getting-started/the-sx-prop/), which provides a quick way to apply ad-hoc styles using theme-aware values to any component created with `styled`.

```tsx
const GithubButton = styled(ButtonUnstyled)(
Expand Down

0 comments on commit 33e6381

Please sign in to comment.