Skip to content

Commit

Permalink
Merge pull request #8598 from marmelab/feature-doc
Browse files Browse the repository at this point in the history
[Doc] Add Features chapter
  • Loading branch information
fzaninotto committed Jan 27, 2023
2 parents 6e887df + dc4e5ca commit e3ee94c
Show file tree
Hide file tree
Showing 18 changed files with 1,648 additions and 42 deletions.
83 changes: 83 additions & 0 deletions docs/AppBar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
layout: default
title: "The AppBar Component"
---

# `<AppBar>`

The default react-admin layout renders a horizontal app bar at the top, which is rendered by the `<AppBar>` component.

![standard layout](./img/layout-component.gif)

By default, the `<AppBar>` component displays:

- a hamburger icon to toggle the sidebar width,
- the application title,
- a button to change locales (if the application uses [i18n](./Translation.md)),
- a loading indicator,
- a button to display the user menu.

You can customize the App Bar by creating a custom component based on `<AppBar>`, with different props.

## Usage

Create a custom app bar based on react-admin's `<AppBar>`:

```jsx
// in src/MyAppBar.js
import { AppBar } from 'react-admin';
import { Typography } from '@mui/material';

const MyAppBar = props => (
<AppBar {...props} color="primary">
<Typography
variant="h6"
color="inherit"
className={classes.title}
id="react-admin-title"
/>
</AppBar>
);
```

Then, create a custom layout based on react-admin's `<Layout>`:

```jsx
// in src/MyLayout.js
import { Layout } from 'react-admin';

import { MyAppBar } from './MyAppBar';

export const MyLayout = props => <Layout {...props} appBar={MyAppBar} />;
```

Then pass this custom layout to the `<Admin>` component:

```jsx
// in src/App.js
import { MyLayout } from './MyLayout';

const App = () => (
<Admin layout={MyLayout} dataProvider={...}>
// ...
</Admin>
);
```

## Props

| Prop | Required | Type | Default | Description |
| ------------------- | -------- | -------------- | -------- | --------------------------------------------------- |
| `children` | Optional | `ReactElement` | - | What to display in the central part of the app bar |
| `color` | Optional | `string` | - | The background color of the app bar |
| `enableColorOnDark` | Optional | `boolean` | - | If true, the `color` prop is applied in dark mode |
| `position` | Optional | `string` | - | The positioning type. |
| `sx` | Optional | `SxProps` | - | Style overrides, powered by MUI System |
| `title` | Optional | `ReactElement` | - | A React element rendered at left side of the screen |
| `userMenu` | Optional | `ReactElement` | - | The content of the dropdown user menu |

Additional props are passed to [the underlying MUI `<AppBar>` element](https://mui.com/material-ui/api/app-bar/).

## Adding Buttons

## Customizing the User Menu
4 changes: 2 additions & 2 deletions docs/Authentication.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
layout: default
title: "Auth Providers"
title: "security"
---

# Auth Providers
# Security

![Login](./img/login.gif)

Expand Down
4 changes: 2 additions & 2 deletions docs/DataProviderIntroduction.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
layout: default
title: "Data Providers"
title: "Data Fetching"
---

# Data Providers
# Data Fetching

Whenever react-admin needs to communicate with your APIs, it does it through an object called the `dataProvider`. The `dataProvider` exposes a predefined interface that allows react-admin to query any API in a normalized way.

Expand Down
Loading

0 comments on commit e3ee94c

Please sign in to comment.