From be1cd239686f86418c292c5e1f863320cfaa9e49 Mon Sep 17 00:00:00 2001 From: fzaninotto Date: Wed, 28 Aug 2019 15:20:22 +0200 Subject: [PATCH] Document form variant and margin --- docs/CreateEdit.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/docs/CreateEdit.md b/docs/CreateEdit.md index 036ccb47236..43cc42d8d8a 100644 --- a/docs/CreateEdit.md +++ b/docs/CreateEdit.md @@ -363,6 +363,8 @@ Here are all the props accepted by the `` component: * [`submitOnEnter`](#submit-on-enter) * [`redirect`](#redirection-after-submission) * [`toolbar`](#toolbar) +* [`variant`](#variant) +* [`margin`](#margin) * `save`: The function invoked when the form is submitted. This is passed automatically by `react-admin` when the form component is used inside `Create` and `Edit` components. * `saving`: A boolean indicating whether a save operation is ongoing. This is passed automatically by `react-admin` when the form component is used inside `Create` and `Edit` components. @@ -394,6 +396,8 @@ Here are all the props accepted by the `` component: * [`submitOnEnter`](#submit-on-enter) * [`redirect`](#redirection-after-submission) * [`toolbar`](#toolbar) +* [`variant`](#variant) +* [`margin`](#margin) * `save`: The function invoked when the form is submitted. This is passed automatically by `react-admin` when the form component is used inside `Create` and `Edit` components. * `saving`: A boolean indicating whether a save operation is ongoing. This is passed automatically by `react-admin` when the form component is used inside `Create` and `Edit` components. @@ -440,6 +444,7 @@ To style the tabs, the `` component accepts two props: - `contentClassName` is passed to the tab *content* ### TabbedFormTabs + By default `` uses ``, an internal react-admin component to renders tabs. You can pass a custom component as the `tabs` prop to override the default component. Besides, props from `` are passed to material-ui's `` component inside ``. The following example shows how to make use of scrollable ``. Pass the `scrollable` prop to `` and pass that as the `tabs` prop to `` @@ -827,6 +832,34 @@ Here are the props received by the `Toolbar` component when passed as the `toolb **Tip**: To alter the form values before submitting, you should use the `handleSubmit` prop. See [Altering the Form Values before Submitting](./Actions.md#altering-the-form-values-before-submitting) for more information and examples. +## Variant + +By default, react-admin input components use the Material Design "filled" variant. If you want to use the "standard" or "outlined" variants, you can either set the `variant` prop on each Input component individually, or set the `variant` prop directly on the Form component. In that case, the Form component will transmit the `variant` to each Input. + +```jsx +export const PostEdit = (props) => ( + + + ... + + +); +``` + +## Margin + +By default, react-admin input components use the Material Design "dense" mrgin. If you want to use the "normal" or "none" margins, you can either set the `margin` prop on each Input component individually, or set the `margin` prop directly on the Form component. In that case, the Form component will transmit the `margin` to each Input. + +```jsx +export const PostEdit = (props) => ( + + + ... + + +); +``` + ## Customizing Input Container Styles The input components are wrapped inside a `div` to ensure a good looking form by default. You can pass a `formClassName` prop to the input components to customize the style of this `div`. For example, here is how to display two inputs on the same line: