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] Add illustration to the <Labeled> chapter #9382

Merged
merged 3 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 6 additions & 4 deletions docs/Labeled.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ title: "Labeled"

# `<Labeled>`

`<Labeled>` adds a label on top of its child if the child exposes a `label` prop, or if it's a field with a `source` prop. It's used in Show layouts, to display both a field and its label.
`<Labeled>` adds a label on top of its child if the child exposes a `label` prop, or if it's a field with a `source` prop. It's used in Show layouts, to display both a field and its label.

![Labeled](./img/Labeled.png)

## Usage

`<Labeled>` is mostly an internal component - you don't need it if you're using `<SimpleShowLayout>` or `<TabbedShowLayout>`. But, in a custom layout or in a form, if you want to display a label on top of a field value, just wrap the Field component with `<Labeled>`.
`<Labeled>` is mostly an internal component - you don't need it if you're using `<SimpleShowLayout>` or `<TabbedShowLayout>`. But, in a custom layout or in a form, if you want to display a label on top of a field value, just wrap the Field component with `<Labeled>`.

```jsx
import { Show, Labeled, TextField } from 'react-admin';
Expand All @@ -30,11 +32,11 @@ const BookShow = () => (

## Label

`<Labeled>` uses the humanized `source`, and renders it above the field value. So for the previous example, the label would be `"Title"`.
`<Labeled>` uses the humanized `source`, and renders it above the field value. So for the previous example, the label would be `"Title"`.

`<Labeled>` uses the i18n layer, so you can translate the label. The message key for a label is `resources.{resource}.fields.{source}` (e.g. `resources.books.fields.title` for the element above). Check [the Translation chapter](./TranslationTranslating.md) for more information.

`<Labeled>` can also use an explicit `label` prop:
`<Labeled>` can also use an explicit `label` prop:

```jsx
import { Show, Labeled, TextField } from 'react-admin';
Expand Down
Binary file added docs/img/Labeled.png
erwanMarmelab marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading