Skip to content
This repository was archived by the owner on Mar 16, 2026. It is now read-only.

Commit 3cfbc50

Browse files
committed
docs: update built-in components
1 parent 7ca8fa2 commit 3cfbc50

1 file changed

Lines changed: 31 additions & 18 deletions

File tree

src/docs/documentation/general/built-in-components.mdx

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@ menu: General
77

88
# Built-in components
99

10-
Docz has built-in components that help you to document your things. Using the power of components and AST to parse and generate data for them, we can do a lot of things,
11-
like render your components, create tables with contents, custom getters by traversing your file, etc. The sky is the limit here!
10+
Docz has built-in components that help you document your code.
11+
12+
Using the power of components and their parsed ASTs ([Abstract Syntax Trees](https://en.wikipedia.org/wiki/Abstract_syntax_tree))
13+
we can do a lot of things, like render your components, create tables with content describing them, generate documentation from your code, define custom getters by traversing your files and many other things.
14+
The sky is the limit here!
1215

1316
## Playground Component
1417

15-
With the `<Playground>` component, you can render your component inside a playground and see the code used:
18+
With the `<Playground>` component, you can render your component inside a live-editable playground and directly see the output of the code used:
1619

1720
```markdown
1821
---
1922
name: Button
23+
route: /
2024
---
2125

2226
import { Playground } from 'docz'
@@ -32,24 +36,29 @@ import { Button } from './Button'
3236
</Playground>
3337
```
3438

35-
![](https://cdn-std.dprcdn.net/files/acc_649651/hrRpoR)
39+
![Page showing two buttons and their code inside an editable playground](https://cdn-std.dprcdn.net/files/acc_649651/hrRpoR)
40+
41+
As you can see, `<Playground>` renders your components, and right below them displays an editable version of the code used.
42+
This can be very useful to test and develop your components in a good environment while also documenting them.
3643

37-
As you see, `<Playground>` rendered your component in a blank state, and right below, displayed the code used to.
38-
This can be very useful to test and develop your components in a good environment while you document it. The code below the component is also editable and the changes you make to that code will reflect live in the component above!
44+
Note that you can edit the code below the components from your browser and see the changes you make be reflected live above it!
3945

4046
## Component Props
4147

42-
Maybe the most important thing when you write a component is know which properties it has.
43-
However, keeping a good properties documentation of your component can be boring, because you need to write
44-
the props specification and maintain the original props definition. And we know that to keep both in sync can be troublesome!
48+
One of the most important things when documenting a component is to know which props it expects.
49+
50+
However, keeping a good properties documentation for your component can be difficult and error-prone, because you need to write
51+
the props specification and maintain the original props definition separately. This makes it hard to keep them both in sync !
4552

46-
Docz offers a solution to this problem called the `<Props>`. It's a simple component that automatically gets the
47-
props definition of your component and display them in a cool component.
48-
Simple like that and works nicely with Flow and Typescript.
53+
Docz offers a solution to this problem called the `<Props>` component. It's a component that automatically gets the
54+
props definitions of your component and displays them in a neat table along with their default value and an optional description.
55+
56+
In addition to supporting parsing `prop-types` in JS code, it works nicely with Flow and Typescript.
4957

5058
```markdown
5159
---
5260
name: Button
61+
route: /
5362
---
5463

5564
import { Playground, Props } from 'docz'
@@ -67,15 +76,17 @@ import { Button } from './'
6776
</Playground>
6877
```
6978

70-
The button that will display the props must have some annotation on the props. For non flow or typescript users this can be achieved with [`prop-types`](https://www.npmjs.com/package/prop-types)
79+
The Button component must have some annotation describing its props.
80+
81+
For non flow or typescript users this can be achieved with [`prop-types`](https://www.npmjs.com/package/prop-types)
7182

7283
```jsx
7384
import React from 'react'
7485
import t from 'prop-types'
7586

7687
const Button = ({ children, kind }) => {
77-
// Do something nice with the kind prop, like add a class with it
78-
return <button>{children}</button>
88+
// We use the kind prop to determine the button's class
89+
return <button className={kind}>{children}</button>
7990
}
8091

8192
Button.propTypes = {
@@ -90,9 +101,9 @@ Button.defaultProps = {
90101
export Button
91102
```
92103

93-
If you have used `prop-types` you should now have a list of properties in a nicely formatted table:
104+
If you have used `prop-types` like described above, you should see a list of properties in a nicely formatted table:
94105

95-
![](https://cdn-std.dprcdn.net/files/acc_649651/KEm5mH)
106+
![Table describing Button's props ](https://cdn-std.dprcdn.net/files/acc_649651/KEm5mH)
96107

97108
The same can be achieved in typescript by adding comments to the props interface of your component:
98109

@@ -107,4 +118,6 @@ interface ButtonProps {
107118
}
108119
```
109120

110-
You can read more in depth about our built-in components on [**Components API**](/docs/components-api). If you are more interested in learning more about the MDX-pages you could head on to [**Document Settings**](/docs/document-settings)
121+
You can read a more in-depth guide about our built-in components in [**Components API**](/docs/components-api).
122+
123+
And if you prefer to dive deeper into MDX document settings you can head over to [**Document Settings**](/docs/document-settings)

0 commit comments

Comments
 (0)