Skip to content

Commit 040f54d

Browse files
committed
Put sections in alphabetical order
1 parent 3bbe22f commit 040f54d

File tree

1 file changed

+35
-27
lines changed

1 file changed

+35
-27
lines changed

docs/CheckboxGroupInput.md

+35-27
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,23 @@ By default, this inputs renders a checkbox and a label for each choice, with the
126126

127127
![labelPlacement bottom](./img/CheckboxGroupInput-labelPlacement.png)
128128

129+
## `options`
130+
131+
Use the `options` attribute if you want to override any of MUI's [MUI Checkbox documentation](https://mui.com/api/checkbox/) attributes:
132+
133+
{% raw %}
134+
```jsx
135+
import { FavoriteBorder, Favorite } from '@mui/icons-material';
136+
137+
<CheckboxGroupInput source="options" options={{
138+
icon: <FavoriteBorder />,
139+
checkedIcon: <Favorite />
140+
}} />
141+
```
142+
{% endraw %}
143+
144+
![row bottom](./img/CheckboxGroupInput-options.png)
145+
129146
## `optionText`
130147

131148
You can customize the properties to use for the option name (instead of the default `name`) thanks to the `optionText` prop:
@@ -140,6 +157,14 @@ const choices = [
140157
<CheckboxGroupInput source="roles" choices={choices} optionText="label" />
141158
```
142159

160+
`optionText` is especially useful when the choices are records coming from a `<ReferenceArrayInput>` or a `<ReferenceManyToManyInput>`. By default, react-admin uses the [`recordRepresentation`](./Resource.md#recordrepresentation) function to display the record label. But if you set the `optionText` prop, react-admin will use it instead.
161+
162+
```jsx
163+
<ReferenceArrayInput source="tag_ids" reference="tags">
164+
<CheckboxGroupInput optionText="tag" />
165+
</ReferenceArrayInput>
166+
```
167+
143168
`optionText` also accepts a function, so you can shape the option text based on the entire choice object:
144169

145170
```jsx
@@ -192,6 +217,16 @@ By default, the checkboxes are displayed in a row. You can change that and let r
192217

193218
![row bottom](./img/CheckboxGroupInput-row.png)
194219

220+
## `sx`: CSS API
221+
222+
The `<CheckboxGroupInput>` component accepts the usual `className` prop. You can also override many styles of the inner components thanks to the `sx` property (as most MUI components, see their [documentation about it](https://mui.com/customization/how-to-customize/#overriding-nested-component-styles)). This property accepts the following subclasses:
223+
224+
| Rule name | Description |
225+
|---------------------------------|----------------------------------------------------------|
226+
| `& .RaCheckboxGroupInput-label` | Applied to the underlying MUI's `FormLabel` component |
227+
228+
To override the style of all instances of `<CheckboxGroupInput>` using the [MUI style overrides](https://mui.com/customization/globals/#css), use the `RaCheckboxGroupInput` key.
229+
195230
## `translateChoice`
196231

197232
The choices are translated by default, so you can use translation identifiers as choices:
@@ -210,30 +245,3 @@ However, in some cases (e.g. inside a `<ReferenceArrayInput>`), you may not want
210245
```jsx
211246
<CheckboxGroupInput source="roles" choices={choices} translateChoice={false}/>
212247
```
213-
214-
## `options`
215-
216-
Use the `options` attribute if you want to override any of MUI's [MUI Checkbox documentation](https://mui.com/api/checkbox/) attributes:
217-
218-
{% raw %}
219-
```jsx
220-
import { FavoriteBorder, Favorite } from '@mui/icons-material';
221-
222-
<CheckboxGroupInput source="options" options={{
223-
icon: <FavoriteBorder />,
224-
checkedIcon: <Favorite />
225-
}} />
226-
```
227-
{% endraw %}
228-
229-
![row bottom](./img/CheckboxGroupInput-options.png)
230-
231-
## `sx`: CSS API
232-
233-
The `<CheckboxGroupInput>` component accepts the usual `className` prop. You can also override many styles of the inner components thanks to the `sx` property (as most MUI components, see their [documentation about it](https://mui.com/customization/how-to-customize/#overriding-nested-component-styles)). This property accepts the following subclasses:
234-
235-
| Rule name | Description |
236-
|---------------------------------|----------------------------------------------------------|
237-
| `& .RaCheckboxGroupInput-label` | Applied to the underlying MUI's `FormLabel` component |
238-
239-
To override the style of all instances of `<CheckboxGroupInput>` using the [MUI style overrides](https://mui.com/customization/globals/#css), use the `RaCheckboxGroupInput` key.

0 commit comments

Comments
 (0)