Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cannot use theme to override input variant #7636

Merged
merged 9 commits into from
May 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion docs/Admin.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,10 @@ See the [Theming documentation](./Theming.md#using-a-custom-menu) for more detai
MUI supports [theming](https://mui.com/customization/themes). This lets you customize the look and feel of an admin by overriding fonts, colors, and spacing. You can provide a custom MUI theme by using the `theme` prop:

```jsx
import { defaultTheme } from 'react-admin';

const theme = {
...defaultTheme,
palette: {
type: 'dark', // Switching the dark mode on is a single property value change.
},
Expand All @@ -290,7 +293,7 @@ const App = () => (

![Dark theme](./img/dark-theme.png)

For more details on predefined themes and custom themes, refer to the [MUI Customization documentation](https://mui.com/customization/themes/).
For more details on predefined themes and custom themes, refer to [the Theming chapter](./Theming.md#global-theme-overrides) of the react-admin documentation.

## `layout`

Expand Down
31 changes: 31 additions & 0 deletions docs/Inputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,37 @@ import { FormDataConsumer } from 'react-admin';
);
```

### Overriding The Input Variant

MUI offers [3 variants for text fields](https://mui.com/material-ui/react-text-field/#basic-textfield): `outlined`, `filled`, and `standard`. The default react-admin theme uses the `filled` variant. If you want your application to use another variant, override the `<Admin theme>` prop with a [custom theme](./Theming.md#global-theme-overrides), as follows:

```jsx
import { defaultTheme } from 'react-admin';

const theme = {
...defaultTheme,
components: {
...defaultTheme.components,
MuiTextField: {
defaultProps: {
variant: 'outlined' as const,
},
},
MuiFormControl: {
defaultProps: {
variant: 'outlined' as const,
},
},
}
};

const App = () => (
<Admin theme={theme}>
// ...
</Admin>
);
```

## Writing Your Own Input Component

If you need a more specific input type, you can write it directly in React. You'll have to rely on react-hook-form's [useController](https://react-hook-form.com/api/usecontroller) hook, to handle the value update cycle.
Expand Down
1 change: 0 additions & 1 deletion docs/Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ title: "Reference"
* `useSortState`
* [`useStore`](./useStore.md)
* [`useStoreContext`](./useStoreContext.md)
* [`useStyles`](./Theming.md#overriding-a-component-style)
* `useSuggestions`
* [`useTheme`](./Theming.md#changing-the-theme-programmatically)
* [`useTour`](https://marmelab.com/ra-enterprise/modules/ra-tour)<img class="icon" src="./img/premium.svg" />
Expand Down
Loading