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

[Doc] Added CSS API for the Toolbar component #5955

Merged
merged 3 commits into from
Feb 25, 2021
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
16 changes: 16 additions & 0 deletions docs/CreateEdit.md
Original file line number Diff line number Diff line change
Expand Up @@ -1625,13 +1625,29 @@ export const PostEdit = (props) => (

Here are the props received by the `Toolbar` component when passed as the `toolbar` prop of the `SimpleForm` or `TabbedForm` components:

* `alwaysEnableSaveButton`: Force enabling the `<SaveButton>`. If it's not defined, the `<SaveButton>` will be enabled using the `pristine` prop (disabled if pristine, enabled otherwise).
* `handleSubmitWithRedirect`: The function to call in order to submit the form. It accepts a single parameter overriding the form's default redirect.
* `handleSubmit` which is the same prop as in [react-final-form](https://final-form.org/docs/react-final-form/types/FormRenderProps#handlesubmit)
* `invalid`: A boolean indicating whether the form is invalid
* `pristine`: A boolean indicating whether the form is pristine (eg: no inputs have been changed yet)
* `redirect`: The default form's redirect
* `saving`: A boolean indicating whether a save operation is ongoing.
* `submitOnEnter`: A boolean indicating whether the form should be submitted when pressing `enter`
* `width`: A string apply to the mobile or desktop classes depending on its value. Pass `xs` to display the mobile version.

### CSS API

The `<Toolbar>` accepts the usual `className` prop but you can override many class names injected to the inner components by React-admin thanks to the `classes` property (as most Material UI components, see their [documentation about it](https://material-ui.com/customization/components/#overriding-styles-with-classes)). This property accepts the following keys:

| Rule name | Description |
| ---------------- | ------------------------------------------------------------------------------- |
| `toolbar` | Applied to the underlying `MuiToolbar` component |
| `defaultToolbar` | Applied to the container of the `<Toolbar>` buttons when no children are passed |
| `desktopToolbar` | Applied to the underlying `MuiToolbar` component when `width` prop is not `xs` |
| `mobileToolbar` | Applied to the underlying `MuiToolbar` component when `width` prop is `xs` |
| `spacer` | Applied to the div below the underlying `MuiToolbar` used as spacer |

To override the style of all instances of `<Toolbar>` components using the [material-ui style overrides](https://material-ui.com/customization/globals/#css), use the `RaToolbar` key.

**Tip**: Use react-admin's `<Toolbar>` component instead of material-ui's `<Toolbar>` component. The former builds upon the latter and adds support for an alternative mobile layout (and is therefore responsive).

Expand Down
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/form/Toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const valueOrDefault = (value, defaultValue) =>
* @typedef {Object} Props the props you can use (other props are injected by the <SimpleForm>)
* @prop {boolean} alwaysEnableSaveButton Force enabling the <SaveButton>. If it's not defined, the <SaveButton> will be enabled using the `pristine` prop (disabled if pristine, enabled otherwise).
* @prop {ReactElement[]} children Customize the buttons you want to display in the <Toolbar>.
* @prop {string} width Apply the mobile or the desktop classes depending on the width. Pass "xs" to display the mobile version.
* @prop {string} width Apply to the mobile or desktop classes depending on its value. Pass `xs` to display the mobile version.
*
*/
const Toolbar: FC<ToolbarProps> = props => {
Expand Down