You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 16, 2026. It is now read-only.
Copy file name to clipboardExpand all lines: src/docs/documentation/general/built-in-components.mdx
+31-18Lines changed: 31 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,16 +7,20 @@ menu: General
7
7
8
8
# Built-in components
9
9
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!
12
15
13
16
## Playground Component
14
17
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:
16
19
17
20
```markdown
18
21
---
19
22
name: Button
23
+
route: /
20
24
---
21
25
22
26
import { Playground } from 'docz'
@@ -32,24 +36,29 @@ import { Button } from './Button'

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.
36
43
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!
39
45
40
46
## Component Props
41
47
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 !
45
52
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.
49
57
50
58
```markdown
51
59
---
52
60
name: Button
61
+
route: /
53
62
---
54
63
55
64
import { Playground, Props } from 'docz'
@@ -67,15 +76,17 @@ import { Button } from './'
67
76
</Playground>
68
77
```
69
78
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)
71
82
72
83
```jsx
73
84
importReactfrom'react'
74
85
importtfrom'prop-types'
75
86
76
87
constButton= ({ 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
The same can be achieved in typescript by adding comments to the props interface of your component:
98
109
@@ -107,4 +118,6 @@ interface ButtonProps {
107
118
}
108
119
```
109
120
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